-module(gleam@bit_builder_test). -compile(no_auto_import). -export([builder_test/0, builder_with_strings_test/0, builder_with_builders_test/0, concat_test/0, from_bit_string_test/0, from_string_test/0]). -spec builder_test() -> nil. builder_test() -> Data = begin _pipe = gleam@bit_builder:from_bit_string(<<1>>), _pipe@1 = gleam@bit_builder:append(_pipe, <<2>>), _pipe@2 = gleam@bit_builder:append(_pipe@1, <<3>>), gleam@bit_builder:prepend(_pipe@2, <<0>>) end, _pipe@3 = Data, _pipe@4 = gleam@bit_builder:to_bit_string(_pipe@3), gleam@should:equal(_pipe@4, <<0, 1, 2, 3>>), _pipe@5 = Data, _pipe@6 = gleam@bit_builder:byte_size(_pipe@5), gleam@should:equal(_pipe@6, 4). -spec builder_with_strings_test() -> nil. builder_with_strings_test() -> Data = begin _pipe = gleam@bit_builder:from_bit_string(<<1>>), _pipe@1 = gleam@bit_builder:append_string(_pipe, <<"2"/utf8>>), _pipe@2 = gleam@bit_builder:append_string(_pipe@1, <<"3"/utf8>>), gleam@bit_builder:prepend_string(_pipe@2, <<"0"/utf8>>) end, _pipe@3 = Data, _pipe@4 = gleam@bit_builder:to_bit_string(_pipe@3), gleam@should:equal(_pipe@4, <<"0"/utf8, 1, "2"/utf8, "3"/utf8>>), _pipe@5 = Data, _pipe@6 = gleam@bit_builder:byte_size(_pipe@5), gleam@should:equal(_pipe@6, 4). -spec builder_with_builders_test() -> nil. builder_with_builders_test() -> Data = begin _pipe = gleam@bit_builder:from_bit_string(<<1>>), _pipe@1 = gleam@bit_builder:append_builder( _pipe, gleam@bit_builder:from_bit_string(<<2>>) ), _pipe@2 = gleam@bit_builder:append_builder( _pipe@1, gleam@bit_builder:from_bit_string(<<3>>) ), gleam@bit_builder:prepend_builder( _pipe@2, gleam@bit_builder:from_bit_string(<<0>>) ) end, _pipe@3 = Data, _pipe@4 = gleam@bit_builder:to_bit_string(_pipe@3), gleam@should:equal(_pipe@4, <<0, 1, 2, 3>>), _pipe@5 = Data, _pipe@6 = gleam@bit_builder:byte_size(_pipe@5), gleam@should:equal(_pipe@6, 4). -spec concat_test() -> nil. concat_test() -> _pipe = [gleam@bit_builder:from_bit_string(<<1, 2>>), gleam@bit_builder:from_bit_string(<<3, 4>>), gleam@bit_builder:from_bit_string(<<5, 6>>)], _pipe@1 = gleam@bit_builder:concat(_pipe), _pipe@2 = gleam@bit_builder:to_bit_string(_pipe@1), gleam@should:equal(_pipe@2, <<1, 2, 3, 4, 5, 6>>). -spec from_bit_string_test() -> nil. from_bit_string_test() -> _pipe = gleam@bit_builder:from_bit_string(<<>>), _pipe@1 = gleam@bit_builder:to_bit_string(_pipe), gleam@should:equal(_pipe@1, <<>>). -spec from_string_test() -> nil. from_string_test() -> _pipe = gleam@bit_builder:from_string(<<""/utf8>>), _pipe@1 = gleam@bit_builder:to_bit_string(_pipe), gleam@should:equal(_pipe@1, <<>>).