diff options
author | Louis Pilfold <louis@lpil.uk> | 2021-08-08 21:21:06 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-08-08 21:21:06 +0100 |
commit | 6176988e37845fd6dde805dc022e85370cbe7d6e (patch) | |
tree | 0495688865e5b88494623aaf859dd8b12e2f45c5 /test | |
parent | b0456846292552c3136b40ba5077fe776cb1f71e (diff) | |
download | gleam_stdlib-6176988e37845fd6dde805dc022e85370cbe7d6e.tar.gz gleam_stdlib-6176988e37845fd6dde805dc022e85370cbe7d6e.zip |
Pure Gleam bit builder
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/bit_builder_test.gleam | 126 |
1 files changed, 62 insertions, 64 deletions
diff --git a/test/gleam/bit_builder_test.gleam b/test/gleam/bit_builder_test.gleam index fac962f..e1ec57b 100644 --- a/test/gleam/bit_builder_test.gleam +++ b/test/gleam/bit_builder_test.gleam @@ -1,77 +1,75 @@ -if erlang { - import gleam/should - import gleam/bit_builder +import gleam/should +import gleam/bit_builder - pub fn builder_test() { - let data = - bit_builder.from_bit_string(<<1>>) - |> bit_builder.append(<<2>>) - |> bit_builder.append(<<3>>) - |> bit_builder.prepend(<<0>>) +pub fn builder_test() { + let data = + bit_builder.from_bit_string(<<1>>) + |> bit_builder.append(<<2>>) + |> bit_builder.append(<<3>>) + |> bit_builder.prepend(<<0>>) - data - |> bit_builder.to_bit_string - |> should.equal(<<0, 1, 2, 3>>) + data + |> bit_builder.to_bit_string + |> should.equal(<<0, 1, 2, 3>>) - data - |> bit_builder.byte_size - |> should.equal(4) - } + data + |> bit_builder.byte_size + |> should.equal(4) +} - pub fn builder_with_strings_test() { - let data = - bit_builder.from_bit_string(<<1>>) - |> bit_builder.append_string("2") - |> bit_builder.append_string("3") - |> bit_builder.prepend_string("0") +pub fn builder_with_strings_test() { + let data = + bit_builder.from_bit_string(<<1>>) + |> bit_builder.append_string("2") + |> bit_builder.append_string("3") + |> bit_builder.prepend_string("0") - data - |> bit_builder.to_bit_string - |> should.equal(<<"0":utf8, 1, "2":utf8, "3":utf8>>) + data + |> bit_builder.to_bit_string + |> should.equal(<<"0":utf8, 1, "2":utf8, "3":utf8>>) - data - |> bit_builder.byte_size - |> should.equal(4) - } + data + |> bit_builder.byte_size + |> should.equal(4) +} - pub fn builder_with_builders_test() { - let data = - bit_builder.from_bit_string(<<1>>) - |> bit_builder.append_builder(bit_builder.from_bit_string(<<2>>)) - |> bit_builder.append_builder(bit_builder.from_bit_string(<<3>>)) - |> bit_builder.prepend_builder(bit_builder.from_bit_string(<<0>>)) +pub fn builder_with_builders_test() { + let data = + bit_builder.from_bit_string(<<1>>) + |> bit_builder.append_builder(bit_builder.from_bit_string(<<2>>)) + |> bit_builder.append_builder(bit_builder.from_bit_string(<<3>>)) + |> bit_builder.prepend_builder(bit_builder.from_bit_string(<<0>>)) - data - |> bit_builder.to_bit_string - |> should.equal(<<0, 1, 2, 3>>) + data + |> bit_builder.to_bit_string + |> should.equal(<<0, 1, 2, 3>>) - data - |> bit_builder.byte_size - |> should.equal(4) - } + data + |> bit_builder.byte_size + |> should.equal(4) +} - pub fn concat_test() { - [ - bit_builder.from_bit_string(<<1, 2>>), - bit_builder.from_bit_string(<<3, 4>>), - bit_builder.from_bit_string(<<5, 6>>), - ] - |> bit_builder.concat - |> bit_builder.to_bit_string - |> should.equal(<<1, 2, 3, 4, 5, 6>>) - } +pub fn concat_test() { + [ + bit_builder.from_bit_string(<<1, 2>>), + bit_builder.from_bit_string(<<3, 4>>), + bit_builder.from_bit_string(<<5, 6>>), + ] + |> bit_builder.concat + |> bit_builder.to_bit_string + |> should.equal(<<1, 2, 3, 4, 5, 6>>) +} - pub fn from_bit_string_test() { - // Regression test: no additional modification of the builder - bit_builder.from_bit_string(<<>>) - |> bit_builder.to_bit_string - |> should.equal(<<>>) - } +pub fn from_bit_string_test() { + // Regression test: no additional modification of the builder + bit_builder.from_bit_string(<<>>) + |> bit_builder.to_bit_string + |> should.equal(<<>>) +} - pub fn from_string_test() { - // Regression test: no additional modification of the builder - bit_builder.from_string("") - |> bit_builder.to_bit_string - |> should.equal(<<>>) - } +pub fn from_string_test() { + // Regression test: no additional modification of the builder + bit_builder.from_string("") + |> bit_builder.to_bit_string + |> should.equal(<<>>) } |