finished test of itoa
This commit is contained in:
parent
175bb7bafb
commit
bafc178caf
@ -89,14 +89,14 @@ shellmatta_retCode_t writeFct(const char* data, uint32_t length)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
static char buffer[1024];
|
static char buffer[1024];
|
||||||
static char historyBuffer[0];
|
static char historyBuffer[4096];
|
||||||
static shellmatta_instance_t instance;
|
static shellmatta_instance_t instance;
|
||||||
|
|
||||||
// initscr();
|
// initscr();
|
||||||
// raw();
|
// raw();
|
||||||
// keypad(stdscr, TRUE);
|
// keypad(stdscr, TRUE);
|
||||||
// noecho();
|
// noecho();
|
||||||
f = open("/dev/pts/5", O_RDWR | O_SYNC);
|
f = open("/dev/pts/1", O_RDWR | O_SYNC);
|
||||||
|
|
||||||
if (f < 0)
|
if (f < 0)
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ TEST_CASE( "shellmatta_insertChars normal call" ) {
|
|||||||
|
|
||||||
utils_insertChars(&inst, "blksdflsd kfjlk", 4);
|
utils_insertChars(&inst, "blksdflsd kfjlk", 4);
|
||||||
|
|
||||||
CHECK( inst.cursor == 4);
|
CHECK( inst.cursor == 12);
|
||||||
REQUIRE( inst.inputCount == 4);
|
REQUIRE( inst.inputCount == 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,51 @@
|
|||||||
#include "src/shellmatta_utils.c"
|
#include "src/shellmatta_utils.c"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
TEST_CASE( "shellmatta_utils.c itoa - 123456" ) {
|
TEST_CASE( "shellmatta_utils.c - itoa - 123456 base 10" ) {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
CHECK( utils_shellItoa(123456, buffer, 16) == 5 );
|
CHECK( utils_shellItoa(123456, buffer, 10) == 6 );
|
||||||
CHECK( "12345" == "12345");
|
|
||||||
REQUIRE( strcmp(buffer, "123456") == 0);
|
REQUIRE( strcmp(buffer, "123456") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "shellmatta_utils.c - itoa - 0x0ABBCCDD base 16") {
|
||||||
|
char buffer[64];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
CHECK( utils_shellItoa(0x0ABBCCDD, buffer, 16) == 7 );
|
||||||
|
REQUIRE( strcmp(buffer, "ABBCCDD") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "shellmatta_utils.c - itoa - -574236 base 10") {
|
||||||
|
char buffer[64];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
CHECK( utils_shellItoa(-574236, buffer, 10) == 7 );
|
||||||
|
REQUIRE( strcmp(buffer, "-574236") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "shellmatta_utils.c - itoa - 0x80000000 base 2") {
|
||||||
|
char buffer[64];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
CHECK( utils_shellItoa(0x80000000, buffer, 2) == 33 );
|
||||||
|
REQUIRE( strcmp(buffer, "-10000000000000000000000000000000") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "shellmatta_utils.c - itoa - 0x7FFFFFFF base 2") {
|
||||||
|
char buffer[64];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
CHECK( utils_shellItoa(0x7FFFFFFF, buffer, 2) == 31 );
|
||||||
|
REQUIRE( strcmp(buffer, "1111111111111111111111111111111") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "shellmatta_utils.c - itoa - 0x7FFFFFFF base 1 - wrong base") {
|
||||||
|
char buffer[64];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
CHECK( utils_shellItoa(0x7FFFFFFF, buffer, 1) == 0 );
|
||||||
|
REQUIRE( strcmp(buffer, "\0") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "shellmatta_utils.c - itoa - 0x7FFFFFFF base 17 - wrong base") {
|
||||||
|
char buffer[64];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
CHECK( utils_shellItoa(0x7FFFFFFF, buffer, 17) == 0 );
|
||||||
|
REQUIRE( strcmp(buffer, "\0") == 0);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user