void run_pre_setup_tests() { // #no_context: context will not be initialized at this point, so log() doesn't work printf("Running pre-setup tests...\n"); printf("\nFinished running pre-setup tests...\n"); } string string_literal_example = "Hello, I am a string literal."; void run_post_setup_tests() { log_warning("Hello, I am a warning :), and I am a big number: %lld", (s64)2935088889357); log_error("Hello, I am an error - %s", "I'm another string"); log_error("This is an error"); printf("Running post-setup tests...\n"); // See: main_thread_base_entry_point { Timed_Block_Print("string_builder_testing"); temp_reset(); push_allocator(temp()); // tip: use auto_reset or auto_release with `thread_context()->arena` // String builder example: // OK. I can work with this. String_Builder* sb = context_builder(); reset_string_builder(sb, true); append(sb, "string_literal_example"); append(sb, " "); print_to_builder(sb, "There are %d cats in the %s", 64, "house.\n"); append(sb, " > "); print_to_builder(sb, "some size_t: %u", (u64)3982739867); append(sb, "\n"); print_to_builder(sb, "the literal: %s", string_literal_example.data); // string result = string_view(sb); string result = builder_to_string(sb); // also frees // print((char*)result.data); log("Hello."); log("log() should automatically append newlines to these prints."); log("If it doesn't, I will be very upset."); log(result); log("Hello. There are %s things here\n", string_literal_example.data); print("Hello, I am just a printed message to stdout\n\n"); // Testing file writes and reads: print("Writing some nonsense to a file.\n"); bool success = write_entire_file("D:/TempLocal/junk.txt", to_view(result)); log("Done. Success: %d\n", success); // push_allocator(allocator(thread_context()->arena)); push_allocator(default_allocator()); string file_path = "D:/Work/OpenBCI/ToolZ/prototyping-gui-main/modules/native-proto-lib/native-sdk-prototyping/src/SignalProcessing.cpp"; ArrayView file_data = read_entire_file(file_path, true, true); log("file_data: \n"); log("%s\n", file_data.data); // #note this is not null-terminated } { // Test hashing: u64 start = 0x512585; u32 sdbm = sdbm_hash(&start, sizeof(u64)); u64 kh = knuth_hash(start); u64 fnv = fnv1a_hash(start); string some_data = "Hello there, my name is Musa"; u64 result = fnv1a_hash_any(some_data.data, some_data.count); } { ArenaTable table; table_init(&table); table_resize(&table, 2048); table_add(&table, (u64)52975125, (u64)5); table_set(&table, (u64)52975125, (u64)99); auto ptr = table_find_pointer(&table, (u64)52975125); printf("ptr.* = %llu\n", *ptr); } printf("\nFinished running post-setup tests...\n"); }