74 lines
2.6 KiB
C++
74 lines
2.6 KiB
C++
void run_pre_setup_tests() {
|
|
// #no_context: context will not be initialized at this point.
|
|
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() {
|
|
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.
|
|
|
|
auto sb = new_string_builder(Arena_Reserve::Size_64K);
|
|
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(GPAllocator());
|
|
string file_path = "D:/Work/OpenBCI/ToolZ/prototyping-gui-main/modules/native-proto-lib/native-sdk-prototyping/src/SignalProcessing.cpp";
|
|
ArrayView<u8> file_data = read_entire_file(file_path, true);
|
|
log("file_data: \n");
|
|
log("%s\n", file_data.data);
|
|
}
|
|
{ // 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<u64, u64> 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");
|
|
} |