diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/015_math_intpow/00_1_0.in | 3 | ||||
| -rw-r--r-- | test/015_math_intpow/00_1_0.out | 1 | ||||
| -rw-r--r-- | test/015_math_intpow/01_x_0.in | 3 | ||||
| -rw-r--r-- | test/015_math_intpow/01_x_0.out | 1 | ||||
| -rw-r--r-- | test/015_math_intpow/02_3_2.in | 3 | ||||
| -rw-r--r-- | test/015_math_intpow/02_3_2.out | 1 | ||||
| -rw-r--r-- | test/015_math_intpow/intpow_tests.c | 26 |
7 files changed, 38 insertions, 0 deletions
diff --git a/test/015_math_intpow/00_1_0.in b/test/015_math_intpow/00_1_0.in new file mode 100644 index 0000000..41c18f9 --- /dev/null +++ b/test/015_math_intpow/00_1_0.in | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | 1.0 | ||
| 2 | 0 | ||
| 3 | 1.0 | ||
diff --git a/test/015_math_intpow/00_1_0.out b/test/015_math_intpow/00_1_0.out new file mode 100644 index 0000000..7326d96 --- /dev/null +++ b/test/015_math_intpow/00_1_0.out | |||
| @@ -0,0 +1 @@ | |||
| Ok | |||
diff --git a/test/015_math_intpow/01_x_0.in b/test/015_math_intpow/01_x_0.in new file mode 100644 index 0000000..1545b05 --- /dev/null +++ b/test/015_math_intpow/01_x_0.in | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | 234324.52324234 | ||
| 2 | 0 | ||
| 3 | 1.0 | ||
diff --git a/test/015_math_intpow/01_x_0.out b/test/015_math_intpow/01_x_0.out new file mode 100644 index 0000000..7326d96 --- /dev/null +++ b/test/015_math_intpow/01_x_0.out | |||
| @@ -0,0 +1 @@ | |||
| Ok | |||
diff --git a/test/015_math_intpow/02_3_2.in b/test/015_math_intpow/02_3_2.in new file mode 100644 index 0000000..b1c935f --- /dev/null +++ b/test/015_math_intpow/02_3_2.in | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | 3.0 | ||
| 2 | 2 | ||
| 3 | 9.0 | ||
diff --git a/test/015_math_intpow/02_3_2.out b/test/015_math_intpow/02_3_2.out new file mode 100644 index 0000000..7326d96 --- /dev/null +++ b/test/015_math_intpow/02_3_2.out | |||
| @@ -0,0 +1 @@ | |||
| Ok | |||
diff --git a/test/015_math_intpow/intpow_tests.c b/test/015_math_intpow/intpow_tests.c new file mode 100644 index 0000000..48b255c --- /dev/null +++ b/test/015_math_intpow/intpow_tests.c | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | #define ABS(x) ((x) < 0 ? (-(x)) : (x)) | ||
| 4 | |||
| 5 | double intpow(double, uint64_t); | ||
| 6 | |||
| 7 | const double tolerance = 1e-6; | ||
| 8 | |||
| 9 | void run(void) { | ||
| 10 | char str[STRLENMAX]; | ||
| 11 | double b, r, c; | ||
| 12 | uint64_t e; | ||
| 13 | |||
| 14 | fgets(str, STRLENMAX, stdin); | ||
| 15 | b = atof(str); | ||
| 16 | fgets(str, STRLENMAX, stdin); | ||
| 17 | e = atoll(str); | ||
| 18 | fgets(str, STRLENMAX, stdin); | ||
| 19 | r = atof(str); | ||
| 20 | |||
| 21 | c = intpow(b, e); | ||
| 22 | if (ABS(r - c) > tolerance) | ||
| 23 | printf("Error! Expected %lf but got %lf\n", r, c); | ||
| 24 | else | ||
| 25 | printf("Ok\n"); | ||
| 26 | } | ||
