// any token before 256 is just the literal char value
// primitive data types
-enum ulas_type { ULAS_SYMBOL = 256, ULAS_INT, ULAS_STR };
+enum ulas_type {
+ ULAS_SYMBOL = 256,
+ ULAS_INT,
+ ULAS_STR,
+ ULAS_EQ,
+ ULAS_NEQ,
+ ULAS_GTEQ,
+ ULAS_LTEQ
+};
// data type value
union ulas_val {
assert((expected_rc) == rc); \
}
+
+#define ASSERT_TOTOK(expected_val, expected_rc, token) \
+ { \
+ int rc = 0; \
+ struct ulas_tok tok = ulas_totok((token), strlen(token), &rc); \
+ assert((expected_rc) == rc); \
+ assert(tok.type == (expected_val)); \
+ free(tok.val.strv); \
+ }
+
void test_totok(void) {
TESTBEGIN("totok");
ASSERT_UNEXPECTED_TOTOK(-1, "1symbol123");
+ // generic tokens with no value
+ ASSERT_TOTOK(ULAS_EQ, 0, "==");
+ ASSERT_TOTOK('=', 0, "=");
+ ASSERT_TOTOK('+', 0, "+");
+
TESTEND("totok");
}