From cb241b35cb2f97416d237559bb6836a86ad746c0 Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Mon, 11 Feb 2019 19:14:42 +0900 Subject: [PATCH 01/10] test runner --- test/.gitignore | 1 + test/Makefile | 23 ++++++++++++++ test/test1.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ test/test1.expected | 7 +++++ 4 files changed, 106 insertions(+) create mode 100644 test/.gitignore create mode 100644 test/Makefile create mode 100644 test/test1.c create mode 100644 test/test1.expected diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..7de0b67 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +*.output diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..b685222 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,23 @@ +CC = cc +AR = ar +RM = rm -f + +.c.o: + $(CC) -c -o $@ $< -I.. + +all: test + +test: exec_test1 + +exec_test1: test1 + ./test1 |& tee test1.output + @diff -u test1.expected test1.output & echo "Error!" + +test1.o: test1.c ../longnumber.h + +test1: test1.o ../liblongnumber.a + $(CC) -o test1 test1.o -llongnumber -L.. + +clean:: + $(RM) test1 + $(RM) test1.o diff --git a/test/test1.c b/test/test1.c new file mode 100644 index 0000000..ef855eb --- /dev/null +++ b/test/test1.c @@ -0,0 +1,75 @@ +#include +#include "longnumber.h" + +void test_ln_create01(void) +{ + LongNumber a; + a = ln_create(10, 0, 0); + ln_print(a, 10+2, "c01"); + ln_free(a); +} + +void test_ln_create02(void) +{ + LongNumber a; + a = ln_create(10, 1, 3); + ln_print(a, 10+2, "c02"); + ln_free(a); +} + +void test_ln_create03(void) +{ + LongNumber a; + a = ln_create(10, 2, 3); + ln_print(a, 10+2, "c03"); + ln_free(a); +} + +void test_ln_add01(void) +{ + LongNumber a, b; + a = ln_create(10, 0, 0); + b = ln_create(10, 0, 0); + ln_add(b, b, a, 10); + ln_print(b, 10+2, "a01"); + ln_free(a); + ln_free(b); +} + +void test_ln_add02(void) +{ + LongNumber a, b; + a = ln_create(10, 1, 3); + b = ln_create(10, 2, 3); + ln_add(b, b, a, 10); + ln_print(b, 10+2, "a02"); + ln_free(a); + ln_free(b); +} + +void test_ln_add03(void) +{ + LongNumber a, b; + a = ln_create(10, 2, 3); + b = ln_create(10, 2, 3); + ln_add(b, b, a, 10); + ln_print(b, 10+2, "a03"); + ln_free(a); + ln_free(b); +} + +int main(void) +{ + ln_init(4); + test_ln_create01(); + test_ln_create02(); + test_ln_create03(); + test_ln_add01(); + test_ln_add02(); + test_ln_add03(); + + ln_init(1); + test_ln_create01(); + + return 0; +} diff --git a/test/test1.expected b/test/test1.expected new file mode 100644 index 0000000..40c8430 --- /dev/null +++ b/test/test1.expected @@ -0,0 +1,7 @@ +c01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 44) +c02 0.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) +c03 0.6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 ( 1- 44) +a01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 44) +a02 0.9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 ( 1- 44) +a03 1.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) +c01 0.0 0 0 0 0 0 0 0 0 0 0 ( 1- 11) From 3fa875129c0723afded30baeed9ec62247944cbe Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Mon, 11 Feb 2019 19:39:19 +0900 Subject: [PATCH 02/10] fix judge method of test result --- test/Makefile | 10 ++++++++-- test/test1.expected | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/Makefile b/test/Makefile index b685222..d065bb6 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,8 +10,13 @@ all: test test: exec_test1 exec_test1: test1 - ./test1 |& tee test1.output - @diff -u test1.expected test1.output & echo "Error!" + @echo "Test1..." + @./test1 |& tee test1.output + @if diff -u test1.expected test1.output; then \ + echo "Test1: clear."; \ + else \ + echo "Test1: failed."; \ + fi test1.o: test1.c ../longnumber.h @@ -21,3 +26,4 @@ test1: test1.o ../liblongnumber.a clean:: $(RM) test1 $(RM) test1.o + $(RM) test1.output diff --git a/test/test1.expected b/test/test1.expected index 40c8430..44624a4 100644 --- a/test/test1.expected +++ b/test/test1.expected @@ -3,5 +3,5 @@ c02 0.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) c03 0.6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 ( 1- 44) a01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 44) a02 0.9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 ( 1- 44) -a03 1.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) +a03 1.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3332 ( 1- 44) c01 0.0 0 0 0 0 0 0 0 0 0 0 ( 1- 11) From 6e4b6cba0f85d4d15c97290d3eb55d94629a9c4f Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Tue, 12 Feb 2019 07:12:31 +0000 Subject: [PATCH 03/10] fix redirect stderr => stdout --- test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index d065bb6..9dfa492 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,7 +11,7 @@ test: exec_test1 exec_test1: test1 @echo "Test1..." - @./test1 |& tee test1.output + @./test1 | tee test1.output 2>&1 @if diff -u test1.expected test1.output; then \ echo "Test1: clear."; \ else \ From f89c76d596d0bc3f165ee8d29f3b717e42d44905 Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Mon, 11 Feb 2019 19:14:42 +0900 Subject: [PATCH 04/10] test runner --- test/.gitignore | 1 + test/Makefile | 23 ++++++++++++++ test/test1.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ test/test1.expected | 7 +++++ 4 files changed, 106 insertions(+) create mode 100644 test/.gitignore create mode 100644 test/Makefile create mode 100644 test/test1.c create mode 100644 test/test1.expected diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..7de0b67 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +*.output diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..b685222 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,23 @@ +CC = cc +AR = ar +RM = rm -f + +.c.o: + $(CC) -c -o $@ $< -I.. + +all: test + +test: exec_test1 + +exec_test1: test1 + ./test1 |& tee test1.output + @diff -u test1.expected test1.output & echo "Error!" + +test1.o: test1.c ../longnumber.h + +test1: test1.o ../liblongnumber.a + $(CC) -o test1 test1.o -llongnumber -L.. + +clean:: + $(RM) test1 + $(RM) test1.o diff --git a/test/test1.c b/test/test1.c new file mode 100644 index 0000000..ef855eb --- /dev/null +++ b/test/test1.c @@ -0,0 +1,75 @@ +#include +#include "longnumber.h" + +void test_ln_create01(void) +{ + LongNumber a; + a = ln_create(10, 0, 0); + ln_print(a, 10+2, "c01"); + ln_free(a); +} + +void test_ln_create02(void) +{ + LongNumber a; + a = ln_create(10, 1, 3); + ln_print(a, 10+2, "c02"); + ln_free(a); +} + +void test_ln_create03(void) +{ + LongNumber a; + a = ln_create(10, 2, 3); + ln_print(a, 10+2, "c03"); + ln_free(a); +} + +void test_ln_add01(void) +{ + LongNumber a, b; + a = ln_create(10, 0, 0); + b = ln_create(10, 0, 0); + ln_add(b, b, a, 10); + ln_print(b, 10+2, "a01"); + ln_free(a); + ln_free(b); +} + +void test_ln_add02(void) +{ + LongNumber a, b; + a = ln_create(10, 1, 3); + b = ln_create(10, 2, 3); + ln_add(b, b, a, 10); + ln_print(b, 10+2, "a02"); + ln_free(a); + ln_free(b); +} + +void test_ln_add03(void) +{ + LongNumber a, b; + a = ln_create(10, 2, 3); + b = ln_create(10, 2, 3); + ln_add(b, b, a, 10); + ln_print(b, 10+2, "a03"); + ln_free(a); + ln_free(b); +} + +int main(void) +{ + ln_init(4); + test_ln_create01(); + test_ln_create02(); + test_ln_create03(); + test_ln_add01(); + test_ln_add02(); + test_ln_add03(); + + ln_init(1); + test_ln_create01(); + + return 0; +} diff --git a/test/test1.expected b/test/test1.expected new file mode 100644 index 0000000..40c8430 --- /dev/null +++ b/test/test1.expected @@ -0,0 +1,7 @@ +c01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 44) +c02 0.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) +c03 0.6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 ( 1- 44) +a01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 44) +a02 0.9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 ( 1- 44) +a03 1.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) +c01 0.0 0 0 0 0 0 0 0 0 0 0 ( 1- 11) From 8ff4213c0e2cce00d454558933aefc17f04a063e Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Mon, 11 Feb 2019 19:39:19 +0900 Subject: [PATCH 05/10] fix judge method of test result --- test/Makefile | 10 ++++++++-- test/test1.expected | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/Makefile b/test/Makefile index b685222..d065bb6 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,8 +10,13 @@ all: test test: exec_test1 exec_test1: test1 - ./test1 |& tee test1.output - @diff -u test1.expected test1.output & echo "Error!" + @echo "Test1..." + @./test1 |& tee test1.output + @if diff -u test1.expected test1.output; then \ + echo "Test1: clear."; \ + else \ + echo "Test1: failed."; \ + fi test1.o: test1.c ../longnumber.h @@ -21,3 +26,4 @@ test1: test1.o ../liblongnumber.a clean:: $(RM) test1 $(RM) test1.o + $(RM) test1.output diff --git a/test/test1.expected b/test/test1.expected index 40c8430..44624a4 100644 --- a/test/test1.expected +++ b/test/test1.expected @@ -3,5 +3,5 @@ c02 0.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) c03 0.6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 ( 1- 44) a01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 44) a02 0.9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 ( 1- 44) -a03 1.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) +a03 1.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3332 ( 1- 44) c01 0.0 0 0 0 0 0 0 0 0 0 0 ( 1- 11) From cfbd45d1f0ad67d92f01fd85a8a170df5917e165 Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Tue, 12 Feb 2019 07:12:31 +0000 Subject: [PATCH 06/10] fix redirect stderr => stdout --- test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index d065bb6..9dfa492 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,7 +11,7 @@ test: exec_test1 exec_test1: test1 @echo "Test1..." - @./test1 |& tee test1.output + @./test1 | tee test1.output 2>&1 @if diff -u test1.expected test1.output; then \ echo "Test1: clear."; \ else \ From 7be27edd27bbe18cc65b2cef1cb924e16a672a5e Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Wed, 13 Feb 2019 03:36:15 +0000 Subject: [PATCH 07/10] fix LongNumber type --- test/test1.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test1.c b/test/test1.c index ef855eb..69cf1d9 100644 --- a/test/test1.c +++ b/test/test1.c @@ -3,7 +3,7 @@ void test_ln_create01(void) { - LongNumber a; + LongNumber *a; a = ln_create(10, 0, 0); ln_print(a, 10+2, "c01"); ln_free(a); @@ -11,7 +11,7 @@ void test_ln_create01(void) void test_ln_create02(void) { - LongNumber a; + LongNumber *a; a = ln_create(10, 1, 3); ln_print(a, 10+2, "c02"); ln_free(a); @@ -19,7 +19,7 @@ void test_ln_create02(void) void test_ln_create03(void) { - LongNumber a; + LongNumber *a; a = ln_create(10, 2, 3); ln_print(a, 10+2, "c03"); ln_free(a); @@ -27,7 +27,7 @@ void test_ln_create03(void) void test_ln_add01(void) { - LongNumber a, b; + LongNumber *a, *b; a = ln_create(10, 0, 0); b = ln_create(10, 0, 0); ln_add(b, b, a, 10); @@ -38,7 +38,7 @@ void test_ln_add01(void) void test_ln_add02(void) { - LongNumber a, b; + LongNumber *a, *b; a = ln_create(10, 1, 3); b = ln_create(10, 2, 3); ln_add(b, b, a, 10); @@ -49,7 +49,7 @@ void test_ln_add02(void) void test_ln_add03(void) { - LongNumber a, b; + LongNumber *a, *b; a = ln_create(10, 2, 3); b = ln_create(10, 2, 3); ln_add(b, b, a, 10); From aafb697e353fe85ed0dbd29cd2d9d96443969539 Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Wed, 13 Feb 2019 12:42:03 +0900 Subject: [PATCH 08/10] =?UTF-8?q?=E5=87=BA=E5=8A=9B=E6=A1=81=E6=95=B0?= =?UTF-8?q?=E3=82=92+1=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test1.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test1.c b/test/test1.c index 69cf1d9..77b8e34 100644 --- a/test/test1.c +++ b/test/test1.c @@ -5,7 +5,7 @@ void test_ln_create01(void) { LongNumber *a; a = ln_create(10, 0, 0); - ln_print(a, 10+2, "c01"); + ln_print(a, 10+1, "c01"); ln_free(a); } @@ -13,7 +13,7 @@ void test_ln_create02(void) { LongNumber *a; a = ln_create(10, 1, 3); - ln_print(a, 10+2, "c02"); + ln_print(a, 10+1, "c02"); ln_free(a); } @@ -21,7 +21,7 @@ void test_ln_create03(void) { LongNumber *a; a = ln_create(10, 2, 3); - ln_print(a, 10+2, "c03"); + ln_print(a, 10+1, "c03"); ln_free(a); } @@ -31,7 +31,7 @@ void test_ln_add01(void) a = ln_create(10, 0, 0); b = ln_create(10, 0, 0); ln_add(b, b, a, 10); - ln_print(b, 10+2, "a01"); + ln_print(b, 10+1, "a01"); ln_free(a); ln_free(b); } @@ -42,7 +42,7 @@ void test_ln_add02(void) a = ln_create(10, 1, 3); b = ln_create(10, 2, 3); ln_add(b, b, a, 10); - ln_print(b, 10+2, "a02"); + ln_print(b, 10+1, "a02"); ln_free(a); ln_free(b); } @@ -53,7 +53,7 @@ void test_ln_add03(void) a = ln_create(10, 2, 3); b = ln_create(10, 2, 3); ln_add(b, b, a, 10); - ln_print(b, 10+2, "a03"); + ln_print(b, 10+1, "a03"); ln_free(a); ln_free(b); } From dcc7c9aae314117cba4db8f5b4fbfd020329905a Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Sat, 16 Feb 2019 17:32:09 +0900 Subject: [PATCH 09/10] unset enviroment variable "COLUMNS" --- test/Makefile | 2 +- test/test1.c | 3 +++ test/test1.expected | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/Makefile b/test/Makefile index 9dfa492..e85c565 100644 --- a/test/Makefile +++ b/test/Makefile @@ -13,7 +13,7 @@ exec_test1: test1 @echo "Test1..." @./test1 | tee test1.output 2>&1 @if diff -u test1.expected test1.output; then \ - echo "Test1: clear."; \ + echo "Test1: passed."; \ else \ echo "Test1: failed."; \ fi diff --git a/test/test1.c b/test/test1.c index 77b8e34..250c979 100644 --- a/test/test1.c +++ b/test/test1.c @@ -1,4 +1,5 @@ #include +#include #include "longnumber.h" void test_ln_create01(void) @@ -60,6 +61,8 @@ void test_ln_add03(void) int main(void) { + unsetenv("COLUMNS"); + ln_init(4); test_ln_create01(); test_ln_create02(); diff --git a/test/test1.expected b/test/test1.expected index 44624a4..6e59098 100644 --- a/test/test1.expected +++ b/test/test1.expected @@ -1,7 +1,13 @@ -c01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 44) -c02 0.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 44) -c03 0.6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 ( 1- 44) -a01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 44) -a02 0.9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 ( 1- 44) -a03 1.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 3332 ( 1- 44) +c01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 40) + 0000 ( 41- 44) +c02 0.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 40) + 3333 ( 41- 44) +c03 0.6666 6666 6666 6666 6666 6666 6666 6666 6666 6666 ( 1- 40) + 6666 ( 41- 44) +a01 0.0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ( 1- 40) + 0000 ( 41- 44) +a02 0.9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 ( 1- 40) + 9999 ( 41- 44) +a03 1.3333 3333 3333 3333 3333 3333 3333 3333 3333 3333 ( 1- 40) + 3332 ( 41- 44) c01 0.0 0 0 0 0 0 0 0 0 0 0 ( 1- 11) From e9b297b1b025fbbc12c1598b1484a1e19917a1df Mon Sep 17 00:00:00 2001 From: Naoki FUKUYASU Date: Sat, 16 Feb 2019 17:34:13 +0900 Subject: [PATCH 10/10] tab -> 4 spaces --- test/test1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test1.c b/test/test1.c index 250c979..ce8c03e 100644 --- a/test/test1.c +++ b/test/test1.c @@ -61,7 +61,7 @@ void test_ln_add03(void) int main(void) { - unsetenv("COLUMNS"); + unsetenv("COLUMNS"); ln_init(4); test_ln_create01();