bool test_file_writer_write_args_system_call (Test *test) { FileWriter *writer; FILE *file_readonly, *file_swap; char *path; TITLE (); CATCH (!(file_readonly = fopen ("stage/file_writer/file", "r"))); CATCH (!(path = directory_current_path ())); CATCH (!string_append (&path, "/stage/file_writer/args")); if (file_exists (path)) { CATCH (!file_remove (path)); } CATCH (!(writer = file_writer_create (path, FileWriterModeTruncate))); file_swap = writer->file; writer->file = file_readonly; CATCH (file_writer_write_args (writer, "%s", "test")); CATCH (error_count () == 0); CATCH (error_at (0).error != ErrorSystemCall); writer->file = file_swap; fclose (file_readonly); file_writer_destroy (writer); string_destroy (path); PASS (); }
bool test_unsigned_long_long_private_max (Test *test) { unsigned int a, b, max; unsigned long long computed; TITLE (); for (max = 1; max < 9; max++) { a = 0; b = 0; unsigned_long_long_private_max (max - 1); do { if (a > max - 1 || b > max - 1 || a + b > max - 1) { CATCH (unsigned_long_long_add (a, b, &computed)); } else { CATCH (!unsigned_long_long_add (a, b, &computed)); CATCH (computed != a + b); } if (a > max - 1 || b > max - 1 || a * b > max - 1) { CATCH (unsigned_long_long_mul (a, b, &computed)); } else { CATCH (!unsigned_long_long_mul (a, b, &computed)); CATCH (computed != a * b); } } while (combinations_a_b (&a, &b, max, max)); } PASS (); }
bool test_size_t_pow_invalid_argument (Test *test) { TITLE (); CATCH (size_t_pow (0, 0, NULL)); CATCH (error_at (0).error != ErrorInvalidArgument); PASS (); }
void RingBufferPoolTest::testConference() { TITLE(); std::string test_id1 = "participant A"; std::string test_id2 = "participant B"; auto mainRingBuffer = rbPool_->getRingBuffer(RingBufferPool::DEFAULT_ID); auto testRingBuffer1 = rbPool_->createRingBuffer(test_id1); auto testRingBuffer2 = rbPool_->createRingBuffer(test_id2); // test bind Participant A with default rbPool_->bindCallID(test_id1, RingBufferPool::DEFAULT_ID); // test bind Participant B with default rbPool_->bindCallID(test_id2, RingBufferPool::DEFAULT_ID); // test bind Participant A with Participant B rbPool_->bindCallID(test_id1, test_id2); ring::AudioSample testint = 12; AudioBuffer testbuf(&testint, 1, AudioFormat::MONO()); // put data test ring buffers mainRingBuffer->put(testbuf); // put data test ring buffers testRingBuffer1->put(testbuf); testRingBuffer2->put(testbuf); }
bool test_size_t_add (Test *test) { size_t result; TITLE (); size_t_private_max (SIZE_MAX); CATCH (!size_t_add (0, 0, NULL)); CATCH (error_count () != 0); CATCH (!size_t_add (1, 0, NULL)); CATCH (!size_t_add (0, 1, NULL)); CATCH (!size_t_add (SIZE_MAX / 2, 0, NULL)); CATCH (!size_t_add (0, SIZE_MAX / 2, NULL)); CATCH (!size_t_add ((SIZE_MAX / 2) + 1, (SIZE_MAX / 2), NULL)); CATCH (!size_t_add ((SIZE_MAX / 2), (SIZE_MAX / 2) + 1, NULL)); CATCH (!size_t_add (0, SIZE_MAX, NULL)); CATCH (!size_t_add (SIZE_MAX, 0, NULL)); CATCH (size_t_add (1, SIZE_MAX, NULL)); CATCH (size_t_add (SIZE_MAX, 1, NULL)); CATCH (size_t_add (SIZE_MAX / 2, SIZE_MAX, NULL)); CATCH (size_t_add (SIZE_MAX, SIZE_MAX / 2, NULL)); CATCH (size_t_add ((SIZE_MAX / 2) + 1, SIZE_MAX, NULL)); CATCH (size_t_add (SIZE_MAX, (SIZE_MAX / 2) + 1, NULL)); CATCH (size_t_add (SIZE_MAX - 1, SIZE_MAX, NULL)); CATCH (size_t_add (SIZE_MAX, SIZE_MAX - 1, NULL)); CATCH (size_t_add (SIZE_MAX, SIZE_MAX, NULL)); result = 1; CATCH (!size_t_add (1, 2, &result)); CATCH (result != 3); CATCH (size_t_add (1, SIZE_MAX, &result)); CATCH (result != 3); PASS (); }
void timed_initial_literal::display(int ind) const { TITLE(timed_initial_literal); LEAF(ts); LEAF(time_stamp); FIELD(effs); };
void length_spec::display(int ind) const { TITLE(length_spec); LEAF(mode); LEAF(lengths); LEAF(lengthp); }
bool test_big_int_add_2 (Test *test) { BigInt *a, *b, *to; int i; TITLE (); CATCH (!(a = big_int_create (0))); CATCH (!(b = big_int_create (0))); CATCH (!(to = big_int_create (0))); a->memory[0] = 5U; b->memory[0] = 5U; for (i = 1; i < 32; i++) { a->memory[i] = 0U; b->memory[i] = 0U; } a->digits = 32; b->digits = 32; CATCH (!big_int_add (a, b, to)); CATCH (to->digits != 33); CATCH (to->memory[0] != 1U); for (i = 1; i < 33; i++) { CATCH (to->memory[i] != 0U); } big_int_destroy (a); big_int_destroy (b); big_int_destroy (to); PASS (); }
bool test_big_int_destroy_invalid_argument (Test *test) { TITLE (); big_int_destroy (NULL); CATCH (error_at (0).error != ErrorInvalidArgument); PASS (); }
bool test_websocket_connect_error (Test *test) { NetWebsocket *websocket; NetClientConnection connection; NetClient *client; TITLE (); CATCH (!(websocket = net_websocket_create (&on_add, &on_close, &on_request))); websocket->test.ConnectError = true; // Connect with client. CATCH (!(client = net_client_create (&client_on_connect, &client_on_connect_error, &client_on_error, NULL))); connection.ip = "127.0.0.1"; connection.port = 8888; net_client_connect (client, &connection); CATCH (!thread_signal_wait (&client_ready)); net_client_destroy (client); net_websocket_destroy (websocket); CATCH (error_at (0).error != ErrorFunctionCall); CATCH (!string_equals (error_at (0).function, "server_on_connect")); PASS (); }
bool test_big_int_add_function_call_2 (Test *test) { BigInt *a, *b, *to; int i; TITLE (); CATCH (!(a = big_int_create (0))); CATCH (!(b = big_int_create (0))); CATCH (!(to = big_int_create (0))); CATCH (!(a->memory = memory_grow (a->memory, 33))); CATCH (!(b->memory = memory_grow (b->memory, 33))); a->memory[0] = 1U; b->memory[0] = 1U; for (i = 1; i < 33; i++) { a->memory[i] = 0U; b->memory[i] = 0U; } a->digits = 33; b->digits = 33; memory_commit_limit (memory_commit_size ()); CATCH (big_int_add (a, b, to)); CATCH (error_at (0).error != ErrorFunctionCall); CATCH (error_at (0).code != 2); big_int_destroy (a); big_int_destroy (b); big_int_destroy (to); PASS (); }
void do_dlopen(void) { TITLE("dlopen"); handle = dlopen("/lib64/libm.so.6", RTLD_LAZY); printf("dlopen: handle = %p\n", handle); }
bool test_print (Test *test) { TITLE (); CATCH (!print (" \b")); CATCH (!print ("%i\b", 1)); PASS (); }
bool test_print_silent (Test *test) { TITLE (); print_silent (true); CATCH (!print ("\nThis should not be visible!\n")); PASS (); }
void assignment::display(int ind) const { TITLE(assignment); LEAF(op); FIELD(f_term); FIELD(expr); }
bool test_big_int_set (Test *test) { BigInt *integer; char *max = "18446744073709551615"; size_t max_length; size_t i; TITLE (); CATCH (!(integer = big_int_create (0))); CATCH (integer->digits != 1); CATCH (integer->memory[0] != (unsigned char)0); CATCH (!big_int_set (integer, (uint64_t)-1)); max_length = string_length (max); CATCH (integer->digits != max_length); for (i = 0; i < max_length; i++) { CATCH (integer->memory[i] != max[i] - '0'); } CATCH (!big_int_set (integer, 123)); CATCH (integer->digits != 3); CATCH (integer->memory[0] != 1); CATCH (integer->memory[1] != 2); CATCH (integer->memory[2] != 3); big_int_destroy (integer); PASS (); }
void comparison::display(int ind) const { TITLE(comparison); LEAF(op); FIELD(arg1); FIELD(arg2); }
bool test_file_path_size_2 (Test *test) { TITLE (); file_path_size (1); CATCH (directory_current_path ()); PASS (); }
void effect_lists::display(int ind) const { TITLE(effect_lists); //list<simple_effect*>::iterator i; LABEL(add_effects); add_effects.display(ind); LABEL(del_effects); del_effects.display(ind); LABEL(forall_effects); forall_effects.display(ind); LABEL(cond_effects); cond_effects.display(ind); LABEL(cond_assign_effects); cond_assign_effects.display(ind); LABEL(assign_effects); assign_effects.display(ind); LABEL(timed_effects); timed_effects.display(ind); }
bool test_file_directory_read_3 (Test *test) { char *path; Directory *directory; List *directories; List *files; TITLE (); CATCH (!(path = directory_current_path ())); CATCH (!string_append (&path, "/stage/1d_1f")); /* d stage/1d_1f f f1 d stage/1d_1f/d1 */ CATCH (!(directory = directory_open (path))); string_destroy (path); CATCH (!directory_read (directory)); CATCH (!directory->directories); CATCH (!directory->files); CATCH (directory->directories->count != 1); CATCH (directory->files->count != 1); directories = directory->directories; files = directory->files; CATCH (!directory_read (directory)); CATCH (directories != directory->directories); CATCH (files != directory->files); directory_close (directory); PASS (); }
void menuStatisticsView(uint8_t event) { TITLE(STR_MENUSTAT); switch(event) { case EVT_KEY_FIRST(KEY_UP): chainMenu(menuStatisticsDebug); break; case EVT_KEY_LONG(KEY_MENU): g_eeGeneral.globalTimer = 0; eeDirty(EE_GENERAL); sessionTimer = 0; break; case EVT_KEY_FIRST(KEY_EXIT): chainMenu(menuMainView); break; } // Session and Total timers lcd_putsAtt(STATS_1ST_COLUMN, FH*1+1, "SES", BOLD); putsTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*1+1, sessionTimer, 0, 0); lcd_putsAtt(STATS_1ST_COLUMN, FH*2+1, "TOT", BOLD); putsTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*2+1, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0); // Throttle special timers lcd_putsAtt(STATS_2ND_COLUMN, FH*0+1, "THR", BOLD); putsTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*0+1, s_timeCumThr, 0, 0); lcd_putsAtt(STATS_2ND_COLUMN, FH*1+1, "TH%", BOLD); putsTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*1+1, s_timeCum16ThrP/16, 0, 0); // Timers for (int i=0; i<TIMERS; i++) { putsStrIdx(STATS_3RD_COLUMN, FH*i+1, "TM", i+1, BOLD); if (timersStates[i].val > 3600) putsTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0); else putsTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, 0, 0); } #if defined(THRTRACE) coord_t traceRd = (s_traceCnt < 0 ? s_traceWr : 0); const coord_t x = 5; const coord_t y = 60; lcd_hline(x-3, y, MAXTRACE+3+3); lcd_vline(x, y-32, 32+3); for (coord_t i=0; i<MAXTRACE; i+=6) { lcd_vline(x+i+6, y-1, 3); } for (coord_t i=1; i<=MAXTRACE; i++) { lcd_vline(x+i, y-s_traceBuf[traceRd], s_traceBuf[traceRd]); traceRd++; if (traceRd>=MAXTRACE) traceRd = 0; if (traceRd==s_traceWr) break; } #endif }
bool test_file_directory_read_4 (Test *test) { char *path; Directory *directory; TITLE (); CATCH (!(path = directory_current_path ())); CATCH (!string_append (&path, "/stage/9d_9f")); /* d stage/9d_9f/d8 d stage/9d_9f/d7 d stage/9d_9f/d1 d stage/9d_9f/d4 d stage/9d_9f/d9 d stage/9d_9f/d2 d stage/9d_9f/d5 d stage/9d_9f/d3 d stage/9d_9f/d6 */ CATCH (!(directory = directory_open (path))); string_destroy (path); CATCH (!directory_read (directory)); CATCH (!directory->directories); CATCH (!directory->files); CATCH (directory->directories->count != 9); CATCH (directory->files->count != 9); directory_close (directory); PASS (); }
bool test_unsigned_long_long_add (Test *test) { unsigned long long result; TITLE (); unsigned_long_long_private_max (ULLONG_MAX); CATCH (!unsigned_long_long_add (0, 0, NULL)); CATCH (error_count () != 0); CATCH (!unsigned_long_long_add (1, 0, NULL)); CATCH (!unsigned_long_long_add (0, 1, NULL)); CATCH (!unsigned_long_long_add (ULLONG_MAX / 2, 0, NULL)); CATCH (!unsigned_long_long_add (0, ULLONG_MAX / 2, NULL)); CATCH (!unsigned_long_long_add ((ULLONG_MAX / 2) + 1, (ULLONG_MAX / 2), NULL)); CATCH (!unsigned_long_long_add ((ULLONG_MAX / 2), (ULLONG_MAX / 2) + 1, NULL)); CATCH (!unsigned_long_long_add (0, ULLONG_MAX, NULL)); CATCH (!unsigned_long_long_add (ULLONG_MAX, 0, NULL)); CATCH (unsigned_long_long_add (1, ULLONG_MAX, NULL)); CATCH (unsigned_long_long_add (ULLONG_MAX, 1, NULL)); CATCH (unsigned_long_long_add (ULLONG_MAX / 2, ULLONG_MAX, NULL)); CATCH (unsigned_long_long_add (ULLONG_MAX, ULLONG_MAX / 2, NULL)); CATCH (unsigned_long_long_add ((ULLONG_MAX / 2) + 1, ULLONG_MAX, NULL)); CATCH (unsigned_long_long_add (ULLONG_MAX, (ULLONG_MAX / 2) + 1, NULL)); CATCH (unsigned_long_long_add (ULLONG_MAX - 1, ULLONG_MAX, NULL)); CATCH (unsigned_long_long_add (ULLONG_MAX, ULLONG_MAX - 1, NULL)); CATCH (unsigned_long_long_add (ULLONG_MAX, ULLONG_MAX, NULL)); result = 1; CATCH (!unsigned_long_long_add (1, 2, &result)); CATCH (result != 3); CATCH (unsigned_long_long_add (1, ULLONG_MAX, &result)); CATCH (result != 3); PASS (); }
bool test_file_directory_find_invalid_argument (Test *test) { char *path; Directory *directory; TITLE (); CATCH (!(path = directory_current_path ())); CATCH (!string_append (&path, "/stage/find")); /* d stage/find f f1 d stage/find/d1 */ CATCH (!(directory = directory_open (path))); string_destroy (path); CATCH (directory_find_file (NULL, "file")); CATCH (error_count () != 1); CATCH (error_at (0).error != ErrorInvalidArgument); error_reset (); CATCH (directory_find_directory (NULL, "directory")); CATCH (error_count () != 1); CATCH (error_at (0).error != ErrorInvalidArgument); error_reset (); CATCH (directory_find_file (directory, NULL)); CATCH (error_count () != 1); CATCH (error_at (0).error != ErrorInvalidArgument); error_reset (); CATCH (directory_find_directory (directory, NULL)); CATCH (error_count () != 1); CATCH (error_at (0).error != ErrorInvalidArgument); error_reset (); directory_close (directory); PASS (); }
bool test_unsigned_long_long_mul (Test *test) { unsigned long long result; TITLE (); unsigned_long_long_private_max (ULLONG_MAX); CATCH (!unsigned_long_long_mul (0, 0, NULL)); CATCH (error_count () != 0); CATCH (!unsigned_long_long_mul (1, 0, NULL)); CATCH (!unsigned_long_long_mul (0, 1, NULL)); CATCH (!unsigned_long_long_mul (1, 1, NULL)); CATCH (!unsigned_long_long_mul (0, ULLONG_MAX, NULL)); CATCH (!unsigned_long_long_mul (ULLONG_MAX, 0, NULL)); CATCH (!unsigned_long_long_mul (1, ULLONG_MAX, NULL)); CATCH (!unsigned_long_long_mul (ULLONG_MAX, 1, NULL)); CATCH (!unsigned_long_long_mul (ULLONG_MAX / 2, 2, NULL)); CATCH (!unsigned_long_long_mul (2, ULLONG_MAX / 2, NULL)); CATCH (unsigned_long_long_mul ((ULLONG_MAX / 2) + 1, 2, NULL)); CATCH (unsigned_long_long_mul (2, (ULLONG_MAX / 2) + 1, NULL)); CATCH (unsigned_long_long_mul (ULLONG_MAX / 2, ULLONG_MAX / 2, NULL)); CATCH (unsigned_long_long_mul (ULLONG_MAX / 2, ULLONG_MAX / 2, NULL)); CATCH (unsigned_long_long_mul (ULLONG_MAX, ULLONG_MAX, NULL)); CATCH (unsigned_long_long_mul (ULLONG_MAX, ULLONG_MAX, NULL)); result = 1; CATCH (!unsigned_long_long_mul (2, 3, &result)); CATCH (result != 6); CATCH (unsigned_long_long_mul (2, ULLONG_MAX, &result)); CATCH (result != 6); PASS (); }
bool test_file_directory_find (Test *test) { char *path; Directory *directory; Directory *found_directory; File *found_file; TITLE (); CATCH (!(path = directory_current_path ())); CATCH (!string_append (&path, "/stage/find")); /* d stage/find f f1 d stage/find/d1 */ CATCH (!(directory = directory_open (path))); string_destroy (path); CATCH (!directory_read (directory)); CATCH (!directory->directories); CATCH (!directory->files); CATCH (directory->directories->count != 1); CATCH (directory->files->count != 1); CATCH (!(found_directory = directory_find_directory (directory, "d1"))); CATCH (!string_equals (found_directory->name, "d1")); CATCH (directory_find_directory (directory, "d2")); CATCH (!(found_file = directory_find_file (directory, "f1"))); CATCH (!string_equals (found_file->name, "f1")); CATCH (directory_find_file (directory, "f2")); directory_close (directory); PASS (); }
bool test_size_t_mul (Test *test) { size_t result; TITLE (); CATCH (!size_t_mul (0, 0, NULL)); CATCH (error_count () != 0); CATCH (!size_t_mul (1, 0, NULL)); CATCH (!size_t_mul (0, 1, NULL)); CATCH (!size_t_mul (1, 1, NULL)); CATCH (!size_t_mul (0, SIZE_MAX, NULL)); CATCH (!size_t_mul (SIZE_MAX, 0, NULL)); CATCH (!size_t_mul (1, SIZE_MAX, NULL)); CATCH (!size_t_mul (SIZE_MAX, 1, NULL)); CATCH (!size_t_mul (SIZE_MAX / 2, 2, NULL)); CATCH (!size_t_mul (2, SIZE_MAX / 2, NULL)); CATCH (size_t_mul ((SIZE_MAX / 2) + 1, 2, NULL)); CATCH (size_t_mul (2, (SIZE_MAX / 2) + 1, NULL)); CATCH (size_t_mul (SIZE_MAX / 2, SIZE_MAX / 2, NULL)); CATCH (size_t_mul (SIZE_MAX / 2, SIZE_MAX / 2, NULL)); CATCH (size_t_mul (SIZE_MAX, SIZE_MAX, NULL)); CATCH (size_t_mul (SIZE_MAX, SIZE_MAX, NULL)); result = 1; CATCH (!size_t_mul (2, 3, &result)); CATCH (result != 6); CATCH (size_t_mul (2, SIZE_MAX, &result)); CATCH (result != 6); PASS (); }
void IpTest::testIpAddrOst() { TITLE(); const IpAddr ipv4 = {"8.8.8.8"}; ost::IPV4Host v4host = ipv4; IpAddr ip = v4host.getAddress(); CPPUNIT_ASSERT(ipv4 == ip); #if HAVE_IPV6 const IpAddr ipv6 = {"2001:4860:4860::8888"}; ost::IPV6Host v6host = ipv6; ip = v6host.getAddress(); CPPUNIT_ASSERT(ipv6 == ip); ost::IPV6Host v6host2 = v6host; ip = v6host2.getAddress(); CPPUNIT_ASSERT(ipv6 == ip); ost::IPV6Host v6host3 = {}; ip = v6host3.getAddress(); CPPUNIT_ASSERT(ip); CPPUNIT_ASSERT(v6host3.getAddressCount() > 0 && v6host3.getAddressCount() < 256); v6host3 = v6host; CPPUNIT_ASSERT(IpAddr(v6host3.getAddress()) == ipv6); CPPUNIT_ASSERT(v6host3.getAddressCount() == 1); v6host3 = v6host2.getAddress(); CPPUNIT_ASSERT(IpAddr(v6host3.getAddress()) == ipv6); CPPUNIT_ASSERT(v6host3.getAddressCount() == 1); #endif }
bool test_encode_base64 (Test *test) { char *base64; char bytes[1024 * 16]; size_t i; TITLE (); CATCH (encode_base64 (NULL, 0)); CATCH (error_at (0).error != ErrorInvalidArgument); CATCH (error_at (0).code != 1); CATCH (encode_base64 ("", 0)); CATCH (error_at (0).error != ErrorInvalidArgument); CATCH (error_at (0).code != 2); memory_commit_limit (0); CATCH (encode_base64 ("abc", 3)); CATCH (error_at (0).error != ErrorFunctionCall); memory_commit_limit (ULLONG_MAX); for (i = 0; i < 1000; i++) { CATCH (!(base64 = encode_base64 ("any carnal pleasure.", 20))); CATCH (!string_equals (base64, "YW55IGNhcm5hbCBwbGVhc3VyZS4=")); string_destroy (base64); } CATCH (!random_open ()); for (i = 0; i < 1000; i++) { CATCH (!random_bytes ((unsigned char *)&bytes, 1024 * 16)); CATCH (!(base64 = encode_base64 (bytes, 1024 * 16))); CATCH (string_length (base64) < 21848); string_destroy (base64); } random_close (); PASS (); }
bool test_object_id (Test *test) { TITLE (); CATCH (object_id () != 0); CATCH (object_id () != 1); CATCH (object_id () != 2); PASS (); }