33#include "sput.h"
44#include "brubeck.h"
55
6- static void must_parse (const char * msg_text , double value , double sample )
6+ static void must_parse (const char * msg_text , double value , double sample , uint8_t modifiers )
77{
88 struct brubeck_statsd_msg msg ;
99 char buffer [128 ];
@@ -13,6 +13,7 @@ static void must_parse(const char *msg_text, double value, double sample)
1313 sput_fail_unless (brubeck_statsd_msg_parse (& msg , buffer , buffer + len ) == 0 , msg_text );
1414 sput_fail_unless (value == msg .value , "msg.value == expected" );
1515 sput_fail_unless (sample == msg .sample_freq , "msg.sample_rate == expected" );
16+ sput_fail_unless (modifiers == msg .modifiers , "msg.modifiers == expected" );
1617}
1718
1819static void must_not_parse (const char * msg_text )
@@ -27,23 +28,26 @@ static void must_not_parse(const char *msg_text)
2728
2829void test_statsd_msg__parse_strings (void )
2930{
30- must_parse ("github.auth.fingerprint.sha1:1|c" , 1 , 1.0 );
31- must_parse ("github.auth.fingerprint.sha1:1|c|@0.1" , 1 , 10.0 );
32- must_parse ("github.auth.fingerprint.sha1:1|g" , 1 , 1.0 );
33- must_parse ("lol:1|ms" , 1 , 1.0 );
34- must_parse ("this.is.sparta:199812|C" , 199812 , 1.0 );
35- must_parse ("this.is.sparta:0012|h" , 12 , 1.0 );
36- must_parse ("this.is.sparta:23.23|g" , 23.23 , 1.0 );
37- must_parse ("this.is.sparta:0.232030|g" , 0.23203 , 1.0 );
38- must_parse ("this.are.some.floats:1234567.89|g" , 1234567.89 , 1.0 );
39- must_parse ("this.are.some.floats:1234567.89|g|@0.025" , 1234567.89 , 40.0 );
40- must_parse ("this.are.some.floats:1234567.89|g|@0.25" , 1234567.89 , 4.0 );
41- must_parse ("this.are.some.floats:1234567.89|g|@0.01" , 1234567.89 , 100.0 );
42- must_parse ("this.are.some.floats:1234567.89|g|@000.0100" , 1234567.89 , 100.0 );
43- must_parse ("this.are.some.floats:1234567.89|g|@1.0" , 1234567.89 , 1.0 );
44- must_parse ("this.are.some.floats:1234567.89|g|@1" , 1234567.89 , 1.0 );
45- must_parse ("this.are.some.floats:1234567.89|g|@1." , 1234567.89 , 1.0 );
46- must_parse ("this.are.some.floats:|g" , 0.0 , 1.0 );
31+ must_parse ("github.auth.fingerprint.sha1:1|c" , 1 , 1.0 , 0 );
32+ must_parse ("github.auth.fingerprint.sha1:1|c|@0.1" , 1 , 10.0 , 0 );
33+ must_parse ("github.auth.fingerprint.sha1:1|g" , 1 , 1.0 , 0 );
34+ must_parse ("lol:1|ms" , 1 , 1.0 , 0 );
35+ must_parse ("this.is.sparta:199812|C" , 199812 , 1.0 , 0 );
36+ must_parse ("this.is.sparta:0012|h" , 12 , 1.0 , 0 );
37+ must_parse ("this.is.sparta:23.23|g" , 23.23 , 1.0 , 0 );
38+ must_parse ("this.is.sparta:0.232030|g" , 0.23203 , 1.0 , 0 );
39+ must_parse ("this.are.some.floats:1234567.89|g" , 1234567.89 , 1.0 , 0 );
40+ must_parse ("this.are.some.floats:1234567.89|g|@0.025" , 1234567.89 , 40.0 , 0 );
41+ must_parse ("this.are.some.floats:1234567.89|g|@0.25" , 1234567.89 , 4.0 , 0 );
42+ must_parse ("this.are.some.floats:1234567.89|g|@0.01" , 1234567.89 , 100.0 , 0 );
43+ must_parse ("this.are.some.floats:1234567.89|g|@000.0100" , 1234567.89 , 100.0 , 0 );
44+ must_parse ("this.are.some.floats:1234567.89|g|@1.0" , 1234567.89 , 1.0 , 0 );
45+ must_parse ("this.are.some.floats:1234567.89|g|@1" , 1234567.89 , 1.0 , 0 );
46+ must_parse ("this.are.some.floats:1234567.89|g|@1." , 1234567.89 , 1.0 , 0 );
47+ must_parse ("this.are.some.floats:|g" , 0.0 , 1.0 , 0 );
48+ must_parse ("this.are.some.floats:1234567.89|g" , 1234567.89 , 1.0 , 0 );
49+ must_parse ("gauge.increment:+1|g" , 1 , 1.0 , BRUBECK_MOD_RELATIVE_VALUE );
50+ must_parse ("gauge.decrement:-1|g" , -1 , 1.0 , BRUBECK_MOD_RELATIVE_VALUE );
4751
4852 must_not_parse ("this.are.some.floats:12.89.23|g" );
4953 must_not_parse ("this.are.some.floats:12.89|a" );
0 commit comments