@@ -29,6 +29,27 @@ static int s_uuid_string_fn(struct aws_allocator *allocator, void *ctx) {
2929
3030AWS_TEST_CASE (uuid_string , s_uuid_string_fn )
3131
32+ static int s_uuid_string_compact_fn (struct aws_allocator * allocator , void * ctx ) {
33+ (void )allocator ;
34+ (void )ctx ;
35+
36+ struct aws_uuid uuid ;
37+ ASSERT_SUCCESS (aws_uuid_init (& uuid ));
38+
39+ uint8_t uuid_array [AWS_UUID_STR_COMPACT_LEN ] = {0 };
40+ struct aws_byte_buf uuid_buf = aws_byte_buf_from_array (uuid_array , sizeof (uuid_array ));
41+ uuid_buf .len = 0 ;
42+
43+ ASSERT_SUCCESS (aws_uuid_to_str_compact (& uuid , & uuid_buf ));
44+ uint8_t zerod_buf [AWS_UUID_STR_COMPACT_LEN ] = {0 };
45+ ASSERT_UINT_EQUALS (AWS_UUID_STR_COMPACT_LEN - 1 , uuid_buf .len );
46+ ASSERT_FALSE (0 == memcmp (zerod_buf , uuid_array , sizeof (uuid_array )));
47+
48+ return AWS_OP_SUCCESS ;
49+ }
50+
51+ AWS_TEST_CASE (uuid_string_compact , s_uuid_string_compact_fn )
52+
3253static int s_prefilled_uuid_string_fn (struct aws_allocator * allocator , void * ctx ) {
3354 (void )allocator ;
3455 (void )ctx ;
@@ -52,6 +73,29 @@ static int s_prefilled_uuid_string_fn(struct aws_allocator *allocator, void *ctx
5273
5374AWS_TEST_CASE (prefilled_uuid_string , s_prefilled_uuid_string_fn )
5475
76+ static int s_prefilled_uuid_string_compact_fn (struct aws_allocator * allocator , void * ctx ) {
77+ (void )allocator ;
78+ (void )ctx ;
79+
80+ struct aws_uuid uuid = {
81+ .uuid_data = {0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A , 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 },
82+ };
83+
84+ uint8_t uuid_array [AWS_UUID_STR_COMPACT_LEN ] = {0 };
85+ struct aws_byte_buf uuid_buf = aws_byte_buf_from_array (uuid_array , sizeof (uuid_array ));
86+ uuid_buf .len = 0 ;
87+
88+ ASSERT_SUCCESS (aws_uuid_to_str_compact (& uuid , & uuid_buf ));
89+
90+ const char * expected_str = "0102030405060708090a0b0c0d0e0f10" ;
91+ struct aws_byte_buf expected = aws_byte_buf_from_c_str (expected_str );
92+ ASSERT_BIN_ARRAYS_EQUALS (expected .buffer , expected .len , uuid_buf .buffer , uuid_buf .len );
93+
94+ return AWS_OP_SUCCESS ;
95+ }
96+
97+ AWS_TEST_CASE (prefilled_uuid_string_compact , s_prefilled_uuid_string_compact_fn )
98+
5599static int s_uuid_string_short_buffer_fn (struct aws_allocator * allocator , void * ctx ) {
56100 (void )allocator ;
57101 (void )ctx ;
@@ -70,6 +114,24 @@ static int s_uuid_string_short_buffer_fn(struct aws_allocator *allocator, void *
70114
71115AWS_TEST_CASE (uuid_string_short_buffer , s_uuid_string_short_buffer_fn )
72116
117+ static int s_uuid_string_compact_short_buffer_fn (struct aws_allocator * allocator , void * ctx ) {
118+ (void )allocator ;
119+ (void )ctx ;
120+
121+ struct aws_uuid uuid ;
122+ ASSERT_SUCCESS (aws_uuid_init (& uuid ));
123+
124+ uint8_t uuid_array [AWS_UUID_STR_COMPACT_LEN - 2 ] = {0 };
125+ struct aws_byte_buf uuid_buf = aws_byte_buf_from_array (uuid_array , sizeof (uuid_array ));
126+ uuid_buf .len = 0 ;
127+
128+ ASSERT_ERROR (AWS_ERROR_SHORT_BUFFER , aws_uuid_to_str_compact (& uuid , & uuid_buf ));
129+
130+ return AWS_OP_SUCCESS ;
131+ }
132+
133+ AWS_TEST_CASE (uuid_string_compact_short_buffer , s_uuid_string_compact_short_buffer_fn )
134+
73135static int s_uuid_string_parse_fn (struct aws_allocator * allocator , void * ctx ) {
74136 (void )allocator ;
75137 (void )ctx ;
0 commit comments