int main(int argc, char **argv) { SpriteList sprites; ParseXML(strref(aXMLExample, sizeof(aXMLExample) - 1), XMLExample_Callback, &sprites); return 0; }
int main(int argc, char **argv) { if (argc > 1) { if (FILE *f = fopen(argv[1], "rb")) { fseek(f, 0, SEEK_END); size_t size = ftell(f); fseek(f, 0, SEEK_SET); if (char *buffer = (char*)malloc(size)) { fread(buffer, size, 1, f); fclose(f); ParseJSON(strref(buffer, size), json_test_print, nullptr); free(buffer); } else fclose(f); } } else { if (!ParseJSON(strref(json_tests, sizeof(json_tests)), json_test_print, nullptr)) return 1; } return 0; }
int main(void) { plan_tests(9); MEMREF act, x = strref("hello, world"); # define S(s) ((s) ? (s) : "(null)") # define TRY(p, l, exp) \ if (!ok(!refcmp(act = subref(x,p,l), strref(exp)), "(%d, %d): %s", p, l, S(exp))) \ fprintf(stderr, "act[%"FSIZE"d]: %.*s\n", act.len, (int)act.len, S(act.ptr)) TRY( 0, 5, "hello"); TRY( 2, 3, "llo"); TRY( -5, 2, "wo"); TRY( -5, 99, "world"); TRY(-12, 2, "he"); TRY( 0, -1, x.ptr); // (len) is unsigned, so (-1) is just a very big positive number. TRY( 0, 0, NULL); TRY( 1, 0, NULL); TRY(-13, 2, NULL); return exit_status(); }
int main(void) { plan_tests(83); #undef TRY #define TRY(tgt,pat) ok(scanstr(tgt,pat) == strstr(tgt,pat), "'%s'~'%s' -> %p:%p", tgt, pat, scanstr(tgt,pat), strstr(tgt,pat)) TRY("", "a"); TRY("hello", ""); TRY("art", "xe"); TRY("hello", "h"); TRY("hello", "e"); TRY("hello", "l"); TRY("hello", "p"); TRY("ab", "cd"); TRY("ab", "ab"); TRY("cab", "ab"); TRY("dcab", "ab"); TRY("edcab", "ab"); TRY("edcabe", "ab"); TRY("fedcabf", "ab"); char ab[] = "ab"; TRY(ab, "abc"); TRY("abc", "xbc"); TRY("abc", "axc"); TRY("abc", "abx"); TRY("abc", "abc"); TRY("abcd", "abc"); TRY("zabcd", "abc"); TRY("yzabcd", "abc"); TRY("xyzabcd", "abc"); TRY("wxyzabcd", "abc"); TRY("xabc", "abc"); TRY("", "abcd"); TRY("a", "abcd"); TRY("ab", "abcd"); TRY("abcd", "xbcd"); TRY("abcd", "axcd"); TRY("abcd", "abxd"); TRY("abcd", "abcx"); TRY("abcd", "abcd"); TRY("abcde", "abcd"); TRY("zabcd", "abcd"); TRY("yzabcd", "abcd"); TRY("xyzabcd", "abcd"); TRY("vwxyzabcd", "abcd"); TRY("uvwxyzabcd", "abcd"); TRY("tuvwxyzabcd", "abcd"); TRY("stuvwxyzabcd", "abcd"); TRY("rstuvwxyzabcd", "abcd"); TRY("qrstuvwxyzabcd", "abcd"); TRY("qrstuvwxyzabcdabcd", "abcd"); TRY("xabcde", "abcd"); TRY("", "abcde"); TRY("a", "abcde"); TRY("ab", "abcde"); TRY("abcde", "xbcd"); TRY("abcde", "axcd"); TRY("abcde", "abxd"); TRY("abcde", "abcx"); TRY("abcde", "abcde"); TRY("abcdee", "abcde"); TRY("zabcde", "abcde"); TRY("yzabcde", "abcde"); TRY("xyzabcde", "abcde"); TRY("vwxyzabcde", "abcde"); TRY("uvwxyzabcde", "abcde"); TRY("tuvwxyzabcde", "abcde"); TRY("stuvwxyzabcde", "abcde"); TRY("rstuvwxyzabcde", "abcde"); TRY("qrstuvwxyzabcde", "abcde"); TRY("qrstuvwxyzabcdeabcde", "abcde"); TRY("xabcdee", "abcde"); char y[] = "451AC87F_1271_3613_1\t2006-09-27T18:52:48|f=<*****@*****.**>|t=<*****@*****.**>|h=__FRAUD_419_REFNUM|h=__HAS_MSGID|h=__MIME_TEXT_ONLY|h=__SANE_MSGID|Size=7477|inbound|action=deliver|p=0.076|S=?q?[BUGS]_BUG_#2653:_failed_to_make|b=ok|r=200.46.204.254|tm=1.00|a=a/eom"; TRY(y,"009"); #undef TRY #define TRY(tgt,pat) ok(scanbrk(tgt,pat) == strpbrk(tgt,pat), "'%s'~[%s] -> %p:%p", tgt, pat, scanbrk(tgt,pat), strpbrk(tgt,pat)) TRY("hello, world", "wa"); TRY("hello, world", "wo"); TRY("hello, world", "xy"); TRY("hello, world", "war"); TRY("hello, world", "dar"); TRY("hello, world", "xyz"); TRY("", ""); TRY("", "abcde"); TRY("abcde", ""); TRY("hello, world", "w"); TRY("abcdefghijklmnopqrstuvwxyz","fghijklmnopqrstuvwxyz"); char x[] = "451A8BF4_1271_3531_1\t2006-09-27T14:34:30|f=<borea"; TRY(x, "ab"); #undef TRY #define TRY(x,y) ok(isign(scancmp(x,y)) == isign(strcmp(x,y)), "'%s'=='%s' -> %d:%d", x,y,scancmp(x,y), strcmp(x,y)); TRY("hello, world", "hello, world"); TRY("hellow, world", "hello, world"); union { double a; char s[99]; } d0, d1; strcpy(d0.s, "hello, world"); strcpy(d1.s, "hello, world"); TRY(d0.s, d1.s); int i, j; for (i = 1; i <= 64; ++i) { for (j = 32; j < 64; ++j) { char * pat = refdup(subref(strref(y), i, j)); if (scanstr(y, pat) != strstr(y, pat)) break; free(pat); } } ok(i == 65, "scanstr[%d,%d]", i, j); __attribute__((aligned(16))) const char edge[] = "0123456789abdef0123456789abcdef"; TRY(edge+1, "01"); return exit_status(); }
strref PoolStr(struct ObjFileStr off, const char *str_pool) { return off.offs>=0 ? strref(str_pool + off.offs) : strref(); }
bool strref_samples() { // separating full path into name, extension, directory strref file_sample("c:\\windows\\system32\\autochk.exe"); strref file_ext = file_sample.after_last('.'); // file extension strref file_name = file_sample.after_last_or_full('\\', '/'); // file name including extension strref file_name_no_ext = file_name.before_last('.'); // file name excluding extension strref file_dir = file_sample.before_last('\\', '/'); // file path excluding name printf("\nfull path: " STRREF_FMT "\nextension: " STRREF_FMT "\nname: " STRREF_FMT "\nname no ext: " STRREF_FMT "\ndirectory: " STRREF_FMT "\n\n", STRREF_ARG(file_sample), STRREF_ARG(file_ext), STRREF_ARG(file_name), STRREF_ARG(file_name_no_ext), STRREF_ARG(file_dir)); // fnv1a helper unsigned int hash = file_sample.fnv1a(); printf("fnv1a hash of \"" STRREF_FMT "\" is 0x%08x\n", STRREF_ARG(file_sample), hash); // find substrings in text strref text("Many gnomes don't live underwater, this is a widely appreciated convenience among fish."); // case insensitive substring find int pos = text.find(strref("THIS")); if (pos < 0 || text[pos] != 't') return false; // find by rolling hash is an option, may be a performance improvement in large text blocks pos = text.find_rh_case(strref("Many")); if (pos < 0 || text[pos] != 'M') return false; pos = text.find_rh_case(strref("widely")); if (pos < 0 || text[pos] != 'w') return false; // search character by character, usually performing well pos = text.find_case("Many"); if (pos < 0 || text[pos] != 'M') return false; // find the position of a secondary search pos = text.find_after_last(' ', 'i'); if (pos < 0 || text[pos] != 'i') return false; // find last string match pos = text.find_last("on"); if (pos < 0 || text[pos] != 'o') return false; pos = text.find(','); if (pos < 0 || text[pos] != ',') return false; pos = text.find_after('i', (strl_t)pos); if (pos < 0 || (text[pos] != 'i' && pos <= text.find('i'))) return false; pos = (int)text.find_or_full(';', 10); if ((strl_t)pos != text.get_len()) return false; pos = (int)text.find_or_full('.', 10); if (pos <= 0 || text[pos] != '.') return false; pos = text.find(strref("this")); if (pos < 0 || text[pos] != 't') return false; pos = text.find("among"); if (pos < 0 || text[pos] != 'a') return false; pos = text.find_case("This"); if (pos >= 0) return false; pos = text.find_case("this"); if (pos < 0 || text[pos] != 't') return false; pos = text.find_last(strref("fi")); if (pos < 0 || text[pos] != 'f') return false; pos = text.find_last("on"); if (pos < 0 || text[pos] != 'o') return false; return true; }
bool strown_samples() { // strown insert strown<64> str("thougth"); str.insert("ugh it was never ca", 3); printf("\"" STRREF_FMT "\"\n", STRREF_ARG(str.get_strref())); // remove all instances of a character str.remove('a'); printf("\"" STRREF_FMT "\"\n", STRREF_ARG(str.get_strref())); // remove a substring by position and length str.remove(2, 10); printf("\"" STRREF_FMT "\"\n", STRREF_ARG(str.get_strref())); // copy and trim trailing whitespace str.copy("whitespaces: "); str.clip_trailing_whitespace(); if (str.get_last()!=':') return false; // find whitespace str.copy("one two three"); if (str.find_whitespace() != 3 || str.find_whitespace_or_full() != 3) return false; // word size count if (str.len_word() != 3) return false; // alphanumeric count str.copy("1701 green"); if (str.len_alphanumeric() != 4) return false; // uppercase str.copy("AbCdEF"); str.toupper(); if (!str.same_str_case("ABCDEF")) return false; // lowercase str.tolower(); if (!str.same_str_case("abcdef")) return false; // copy a substring within a string str.copy("0123456789abcdefghijklmnopqrstuvwxyz"); str.substrcopy(5, 1, 10); if (!str.same_str_case("056789abcdebcdefghijklmnopqrstuvwxyz")) return false; // format with {} notation strref aArgs[] = { strref("test argument 0"), strref("sample param 1") }; str.format("\\t\\{1} is {1}\\n\\t\\{0} is {0}\\n", aArgs); printf(STRREF_FMT, STRREF_ARG(str.get_strref())); // sprintf with standard c style variadic printf rules str.sprintf("any %.2f horse is mean.", 0.5f); str.sprintf_append(" which is complete %s\n", "horse"); printf(STRREF_FMT, STRREF_ARG(str)); return true; }
bool wildcard_samples() { // wildcard search examples strref search_text("in 2 out of 5 cases the trees will outnumber the carrots, willoutnumber"); // basic wildcard find substring (*) strref search("the*will"); strref substr = search_text.find_wildcard(search); printf("found \"" STRREF_FMT "\" matching \"" STRREF_FMT "\"\n", STRREF_ARG(substr), STRREF_ARG(search)); if (!substr.same_str_case("the trees will")) return false; // find word beginning with c substr = search_text.find_wildcard("<c*>"); if (!substr.same_str_case("cases")) return false; // find word ending with e substr = search_text.find_wildcard("<*%e>"); if (!substr.same_str_case("the")) return false; // find whole line substr = search_text.find_wildcard("@*^"); if (!substr.same_str_case(search_text)) return false; // using ranges and single character number substr = search_text.find_wildcard(strref("[0-9] out of #")); if (!substr.same_str_case("2 out of 5")) return false; // searching any substring between two ranged characters substr = search_text.find_wildcard(strref("#*[0-9]")); if (!substr.same_str_case("2 out of 5")) return false; // searching for substring but spaces are not allowed substr = search_text.find_wildcard("will*{! }number"); printf("substr = " STRREF_FMT "\n", STRREF_ARG(substr)); if (!substr.same_str_case("willoutnumber")) return false; // find r folloed by numbers without another substring to find substr = strref("no k12 r13 [99]").find_wildcard("r*{0-9}"); if (!substr.same_str_case("r13")) return false; // search wildcard iteratively search = "radio, gorilla, zebra, monkey, human, rat, car, ocelot, conrad, butler"; substr.clear(); printf("Words with 'r': "); while ((substr = search.wildcard_after("<*$r*$>", substr))) printf("\"" STRREF_FMT "\" ", STRREF_ARG(substr)); printf("\n"); // search for a more complex expression search = strref(aSomeFiles, sizeof(aSomeFiles)-1); substr.clear(); printf("Lines with two subsequent characters d-e (dd, de, ed, ee) and only alphanumeric or dot after:\n"); while ((substr = search.wildcard_after("@*@[d-e][d-e]*{0-9A-Za-z.}^", substr))) { printf("\"" STRREF_FMT "\"\n", STRREF_ARG(substr)); } substr.clear(); printf("\n.json files:\n\n"); while ((substr = search.wildcard_after("<*{!/}.json^", substr))) { printf("\"" STRREF_FMT "\"\n", STRREF_ARG(substr)); } printf("\nsome words with a character a-f followed by a character that is not a-f:\n\n"); search = strref(aTextSample, sizeof(aTextSample)-1); substr.clear(); while ((substr = search.wildcard_after("<*$[a-f][!a-f\\1-\\x40]*>", substr))) { printf("\"" STRREF_FMT "\" ", STRREF_ARG(substr)); } printf("\n"); return true; }
int main() { try { TestSection("StdTerms"); TestSubsection("TermGarbage"); { MyTestTerm *term1 = new MyTestTerm(10); MyTestTerm2 *term2 = new MyTestTerm2(20); SReference ref1(term1); SReference ref2(term2); SReference ref3(new MyTestTerm(30)); SReference ref4(new MyTestTerm2(40)); TEST("constructed", constructed, 4); TEST("noone-destructed", destructed, 0); ref4 = new MyTestTerm(300); TEST("assign_ptr", destructed, 1); ref4 = ref1; TEST("assign_ref", destructed, 2); ref3 = 0; TEST("assign_null", destructed, 3); } TEST("correctness", constructed, destructed); { constructed = destructed = 0; SReference ref1(new MyTestTerm(200)); SReference ref2(new MyTestTerm(300)); TESTB("before_assigning_refs",constructed == 2 && destructed == 0); ref1 = ref2; TEST("after_assigning_refs", destructed, 1); } TestSubsection("TermType"); { SReference ref5(new MyTestTerm(50)); TESTB("type-of", ref5->TermType() == MyTestTerm::TypeId); TESTB("not-type-of", ref5->TermType() != MyTestTerm2::TypeId); TESTB("subtype", ref5->TermType().IsSubtypeOf(SExpression::TypeId)); TESTB("not-subtype", !(ref5->TermType().IsSubtypeOf(MyTestTerm2::TypeId))); SReference ref6(new MyTestTerm22(60)); TESTB("subtype2_", ref6->TermType() == MyTestTerm22::TypeId); TESTB("22subE", MyTestTerm22::TypeId.IsSubtypeOf(SExpression::TypeId)); TESTB("22sub2", MyTestTerm22::TypeId.IsSubtypeOf(MyTestTerm2::TypeId)); TESTB("2subE", MyTestTerm2::TypeId.IsSubtypeOf(SExpression::TypeId)); TESTB("subtype2", ref6->TermType().IsSubtypeOf(SExpression::TypeId)); TESTB("subtype22", ref6->TermType().IsSubtypeOf(MyTestTerm2::TypeId)); TESTB("subtype22_self", ref6->TermType().IsSubtypeOf(MyTestTerm22::TypeId)); SReference ref7(new MyTestTerm2(70)); TESTB("not-subtype22", !(ref7->TermType().IsSubtypeOf(MyTestTerm22::TypeId))); } TestSubsection("TermCasts"); { SReference ref(new MyTestTerm(50)); SReference ref2(new MyTestTerm2(70)); TESTB("cast_to_lterm", ref.DynamicCastGetPtr<SExpression>() == ref.GetPtr()); TESTB("cast_to_lterm2", ref.DynamicCastGetPtr<SExpression>() == ref.GetPtr()); TESTB("cast_to_itself", ref.DynamicCastGetPtr<MyTestTerm>() == ref.GetPtr()); TESTB("failed_cast", ref.DynamicCastGetPtr<MyTestTerm2>()==0); } TestSubsection("SExpressionCasts"); { SReference ref(new MyTestTerm(50)); SReference ref2(new MyTestTerm2(70)); TESTB("cast_to_lterm", ref.DynamicCastGetPtr<SExpression>() == ref.GetPtr()); TESTB("cast_to_lterm2", ref.DynamicCastGetPtr<SExpression>() == ref.GetPtr()); TESTB("cast_to_itself", ref.DynamicCastGetPtr<MyTestTerm>() == ref.GetPtr()); TESTB("failed_cast", ref.DynamicCastGetPtr<MyTestTerm2>()==0); } TestSubsection("BasicTerms"); { SReference intref(25); TESTC("integer_term", intref->TermType(), SExpressionInt::TypeId); TEST("integer_value", intref.GetInt(), 25); SReference floatref(25.0); TESTC("float_term", floatref->TermType(), SExpressionFloat::TypeId); TESTC("float_value", floatref.GetFloat(), (intelib_float_t)25.0); SReference strref("A_STRING"); TESTC("pchar_term", strref->TermType(), SExpressionString::TypeId); TESTC("pchar_value", strcmp((const char*)strref.GetString(), "A_STRING"), 0); SReference charref('a'); TESTC("char_term", charref->TermType(), SExpressionChar::TypeId); TEST("char_value", charref.GetSingleChar(), 'a'); } TestSubsection("SExpressionString"); { SReference strref1(new SExpressionString("A", "B")); TEST("concatenation_1_1", strref1.GetString(), "AB"); SReference strref2(new SExpressionString("AA", "BB")); TEST("concatenation_2_2", strref2.GetString(), "AABB"); SReference strref3(new SExpressionString("AAA", "BBB")); TEST("concatenation_3_3", strref3.GetString(), "AAABBB"); SReference strref4(new SExpressionString("AAAA", "BBBB")); TEST("concatenation_4_4", strref4.GetString(), "AAAABBBB"); SReference strref5(new SExpressionString("AAAAA", "BBBBB")); TEST("concatenation_5_5", strref5.GetString(), "AAAAABBBBB"); SReference strref6(new SExpressionString("A")); TEST("construction1", strref6.GetString(), "A"); SReference strref7(new SExpressionString("AA")); TEST("construction2", strref7.GetString(), "AA"); SReference strref8(new SExpressionString("AAA")); TEST("construction3", strref8.GetString(), "AAA"); SReference strref9(new SExpressionString("AAAA")); TEST("construction4", strref9.GetString(), "AAAA"); } TestSubsection("SString"); { SString str1; TESTC("default_is_empty", str1.c_str()[0], '\0'); SString str2(""); TESTC("empty_strings", str1, str2); TESTC("empty_is_empty", str2.c_str()[0], '\0'); SString str3("AAA"); SString str4("BBB"); SString str5 = str3 + str4; TEST("string_addition", str5.c_str(), "AAABBB"); SString str6("CCC"); str6 += "DDD"; TEST("string_increment_by_pchar", str6.c_str(), "CCCDDD"); SString str7("EEE"); SString str8("FFF"); str7 += str8; TEST("string_increment_by_string", str7.c_str(), "EEEFFF"); SString str10("Final countdown"); SString str11("Final"); str11 += " countdown"; TESTB("string_equals_itself", str10 == str10); TESTB("string_doesnt_differ_from_itself", !(str10 != str10)); TESTB("two_equal_strings", str10 == str11); TESTB("equal_strings_dont_differ", !(str10 != str11)); SString str12("Another string"); TESTB("two_non_equal_strings", str11 != str12); TESTB("nonequals_non_equal", !(str11 == str12)); SString str13; SString str14(""); TESTB("empty_strings_equal", str13 == str14); TESTB("empty_strings_dont_differ", !(str13 != str14)); SReference strref("my_string"); SString str15(strref); TEST("string_from_lreference", str15.c_str(), "my_string"); { int flag = 0; try { SReference ref(25); SString str(ref); } catch(IntelibX_not_a_string lx) { flag = 0x56; } TESTB("string_from_int_fails", flag == 0x56); } } TestSubsection("TextRepresentation"); { SReference intref(100); TEST("integer_text_rep", intref->TextRepresentation().c_str(), "100"); char buf[100]; intelib_float_t fl; fl = 100.1; SReference fltref(fl); snprintf(buf, sizeof(buf), INTELIB_FLOAT_FORMAT, fl); TEST("float_text_rep", fltref->TextRepresentation().c_str(), buf); fl = 100.0; SReference fltref2(fl); snprintf(buf, sizeof(buf), INTELIB_FLOAT_FORMAT, fl); TEST("float2_text_rep", fltref2->TextRepresentation().c_str(), buf); SReference strref("mystring"); TEST("string_text_rep", strref->TextRepresentation().c_str(), "\"mystring\""); SReference unbound; SReference unbound2; SReference unblist(unbound, unbound2); TEST("unbound_text_representation", unblist->TextRepresentation().c_str(), "(#<UNBOUND> . #<UNBOUND>)"); } TestSubsection("DottedPairs"); { SReference pairref(25, 36); TEST("pair_25_36", pairref->TextRepresentation().c_str(), "(25 . 36)"); SReference dotlistref(25, SReference(36, 49)); TEST("dotlist_25_36_49", dotlistref->TextRepresentation().c_str(), "(25 36 . 49)"); SReference empty_list_ref(*PTheEmptyList); TEST("empty_list_ref", empty_list_ref->TextRepresentation().c_str(), (*PTheEmptyList)->TextRepresentation().c_str()); TESTB("empty_list_equal_empty", empty_list_ref.GetPtr() == PTheEmptyList->GetPtr()); TESTB("dot_list_notequal_empty", dotlistref.GetPtr() != PTheEmptyList->GetPtr()); SReference list25ref(25, *PTheEmptyList); TEST("list_1_elem", list25ref->TextRepresentation().c_str(), "(25)"); SReference list_16_25_ref(16, list25ref); TEST("cons_with_list", list_16_25_ref->TextRepresentation().c_str(), "(16 25)"); SReference list_of_lists_ref(list25ref, SReference(list25ref, *PTheEmptyList)); TEST("list_of_lists", list_of_lists_ref->TextRepresentation().c_str(), "((25) (25))"); } TestSubsection("SExpressionLabel"); { SExpressionLabel *lab1 = new SExpressionLabel("lab1"); SReference labref(lab1); TEST("label", labref->TextRepresentation().c_str(), "lab1"); TESTB("label_equality", labref == SReference(lab1)); SReference labref2(lab1); TESTB("label_equality2", labref== labref2); SReference ref3(25); TESTB("label_non_eq", labref != ref3); #if 0 // no support for booleans in sexpression core TEST("boolean_true", LTheLispBooleanTrue.TextRepresentation().c_str(), #if CLSTYLE_BOOLEANS == 0 "#T" #else "T" #endif ); #endif } TestSubsection("SListConstructor"); { SListConstructor L; SReference list_int((L|25)); TEST("list_of_1_int", list_int->TextRepresentation().c_str(), "(25)"); SReference list_str((L|"abcd")); TEST("list_of_1_str", list_str->TextRepresentation().c_str(), "(\"abcd\")"); intelib_float_t fl = 1.1; SReference list_float((L|fl)); char buf[128]; snprintf(buf, sizeof(buf), "(" INTELIB_FLOAT_FORMAT ")", fl); TEST("list_of_1_float", list_float->TextRepresentation().c_str(), buf); } TestSubsection("ListConstructionAlgebra"); { SListConstructor L; SReference listref((L|25, 36, 49, "abcd", "efgh")); TEST("plain_list", listref->TextRepresentation().c_str(), "(25 36 49 \"abcd\" \"efgh\")"); SReference listref2((L|(L|25), 36, (L|(L|(L|49))))); TEST("list_with_lists", listref2->TextRepresentation().c_str(), "((25) 36 (((49))))"); SReference listref3((L|(L|(L|(L|(L)))))); TEST("empty_buried_list", listref3->TextRepresentation().c_str(), (SString("((((")+ (*PTheEmptyList)-> TextRepresentation().c_str()+ SString("))))")).c_str()); SReference dotpairref((L|25 || 36)); TEST("dotted_pair", dotpairref->TextRepresentation().c_str(), "(25 . 36)"); SReference dotlistref((L|9, 16, 25)||36); TEST("dotted_list", dotlistref->TextRepresentation().c_str(), "(9 16 25 . 36)"); SReference dotpairref2((L|25)^36); TEST("dotted_pair", dotpairref2->TextRepresentation().c_str(), "((25) . 36)"); SReference dotlistref2((L|9, 16, 25)^36); TEST("dotted_list", dotlistref2->TextRepresentation().c_str(), "((9 16 25) . 36)"); SReference just_a_cons(SReference("abc")^SReference(225)); TEST("cons_with_^", just_a_cons->TextRepresentation().c_str(), "(\"abc\" . 225)"); SReference empty(L); empty,25; TEST("comma_on_empty_list", empty->TextRepresentation().c_str(), "(25)"); } TestSubsection("IsEql"); { SReference five(5); TESTB("is_eql_numbers", five.IsEql(5)); TESTB("isnt_eql_numbers", !five.IsEql(3)); TESTB("isnt_eql_num_to_string", !five.IsEql("abc")); SReference abc("abc"); TESTB("is_eql_strings", abc.IsEql("abc")); TESTB("isnt_eql_strings", !abc.IsEql("def")); TESTB("isnt_eql_string_to_num", !abc.IsEql(5)); } TestSubsection("UnboundByDefault"); { SReference unbound; TESTB("sreference_unbound", !unbound.GetPtr()); GenericSReference<MyTestTerm22, IntelibX_wrong_expression_type> p; TESTB("gensref_unbound", !p.GetPtr()); } #if 0 // no support for booleans TestSubsection("Booleans"); { SReference true_ref(LTheLispBooleanTrue); TESTB("boolean_true", true_ref->IsTrue()); SReference false_ref(LTheLispBooleanFalse); TESTB("boolean_false", !(false_ref->IsTrue())); SReference some_ref(25); TESTB("boolean_some", some_ref->IsTrue()); } #endif TestSubsection("Epilogue"); TEST("final-cleanup", destructed, constructed); TestScore(); } catch(...) { printf("Something strange caught\n"); } return 0; }