サンプルに、三角形判定プログラムとそのテストを追加
authorj8takagi <j8takagi@nifty.com>
Thu, 9 Dec 2010 23:28:10 +0000 (08:28 +0900)
committerj8takagi <j8takagi@nifty.com>
Sun, 12 Dec 2010 23:56:32 +0000 (08:56 +0900)
70 files changed:
sample/triangle/Makefile [new file with mode: 0644]
sample/triangle/test/.gitignore [new file with mode: 0644]
sample/triangle/test/01_scalene/0.txt [new file with mode: 0644]
sample/triangle/test/01_scalene/Makefile [new file with mode: 0644]
sample/triangle/test/01_scalene/cmd [new file with mode: 0755]
sample/triangle/test/01_scalene/desc.txt [new file with mode: 0644]
sample/triangle/test/02_equilateral/0.txt [new file with mode: 0644]
sample/triangle/test/02_equilateral/02_equilateral [new file with mode: 0644]
sample/triangle/test/02_equilateral/Makefile [new file with mode: 0644]
sample/triangle/test/02_equilateral/cmd [new file with mode: 0755]
sample/triangle/test/02_equilateral/desc.txt [new file with mode: 0644]
sample/triangle/test/03_isosceles/0.txt [new file with mode: 0644]
sample/triangle/test/03_isosceles/03_isosceles [new file with mode: 0644]
sample/triangle/test/03_isosceles/Makefile [new file with mode: 0644]
sample/triangle/test/03_isosceles/cmd [new file with mode: 0755]
sample/triangle/test/03_isosceles/desc.txt [new file with mode: 0644]
sample/triangle/test/04_isosceles_c/0.txt [new file with mode: 0644]
sample/triangle/test/04_isosceles_c/04_isosceles_c [new file with mode: 0644]
sample/triangle/test/04_isosceles_c/Makefile [new file with mode: 0644]
sample/triangle/test/04_isosceles_c/cmd [new file with mode: 0755]
sample/triangle/test/04_isosceles_c/desc.txt [new file with mode: 0644]
sample/triangle/test/05_zero/0.txt [new file with mode: 0644]
sample/triangle/test/05_zero/05_zero [new file with mode: 0644]
sample/triangle/test/05_zero/Makefile [new file with mode: 0644]
sample/triangle/test/05_zero/cmd [new file with mode: 0755]
sample/triangle/test/05_zero/desc.txt [new file with mode: 0644]
sample/triangle/test/06_minus/0.txt [new file with mode: 0644]
sample/triangle/test/06_minus/06_minus [new file with mode: 0644]
sample/triangle/test/06_minus/Makefile [new file with mode: 0644]
sample/triangle/test/06_minus/cmd [new file with mode: 0755]
sample/triangle/test/06_minus/desc.txt [new file with mode: 0644]
sample/triangle/test/07_line/0.txt [new file with mode: 0644]
sample/triangle/test/07_line/07_line [new file with mode: 0644]
sample/triangle/test/07_line/Makefile [new file with mode: 0644]
sample/triangle/test/07_line/cmd [new file with mode: 0755]
sample/triangle/test/07_line/desc.txt [new file with mode: 0644]
sample/triangle/test/08_lines/0.txt [new file with mode: 0644]
sample/triangle/test/08_lines/08_lines [new file with mode: 0644]
sample/triangle/test/08_lines/Makefile [new file with mode: 0644]
sample/triangle/test/08_lines/cmd [new file with mode: 0755]
sample/triangle/test/08_lines/desc.txt [new file with mode: 0644]
sample/triangle/test/09_less/0.txt [new file with mode: 0644]
sample/triangle/test/09_less/09_less [new file with mode: 0644]
sample/triangle/test/09_less/Makefile [new file with mode: 0644]
sample/triangle/test/09_less/cmd [new file with mode: 0755]
sample/triangle/test/09_less/desc.txt [new file with mode: 0644]
sample/triangle/test/10_lesses/0.txt [new file with mode: 0644]
sample/triangle/test/10_lesses/Makefile [new file with mode: 0644]
sample/triangle/test/10_lesses/cmd [new file with mode: 0755]
sample/triangle/test/10_lesses/desc.txt [new file with mode: 0644]
sample/triangle/test/11_zeroall/0.txt [new file with mode: 0644]
sample/triangle/test/11_zeroall/11_zeroall [new file with mode: 0644]
sample/triangle/test/11_zeroall/Makefile [new file with mode: 0644]
sample/triangle/test/11_zeroall/cmd [new file with mode: 0755]
sample/triangle/test/11_zeroall/desc.txt [new file with mode: 0644]
sample/triangle/test/12_notint/0.txt [new file with mode: 0644]
sample/triangle/test/12_notint/12_notint [new file with mode: 0644]
sample/triangle/test/12_notint/Makefile [new file with mode: 0644]
sample/triangle/test/12_notint/cmd [new file with mode: 0755]
sample/triangle/test/12_notint/desc.txt [new file with mode: 0644]
sample/triangle/test/13_argcnt/0.txt [new file with mode: 0644]
sample/triangle/test/13_argcnt/Makefile [new file with mode: 0644]
sample/triangle/test/13_argcnt/cmd [new file with mode: 0755]
sample/triangle/test/13_argcnt/desc.txt [new file with mode: 0644]
sample/triangle/test/Define.mk [new symlink]
sample/triangle/test/Define_group.mk [new symlink]
sample/triangle/test/Define_test.mk [new symlink]
sample/triangle/test/Makefile [new symlink]
sample/triangle/test/Test.mk [new symlink]
sample/triangle/triangle.c [new file with mode: 0644]

diff --git a/sample/triangle/Makefile b/sample/triangle/Makefile
new file mode 100644 (file)
index 0000000..f4889bd
--- /dev/null
@@ -0,0 +1,9 @@
+.PHONY: all clean
+
+all: triangle
+
+triangle: triangle.c
+       $(CC) -o triangle triangle.c
+
+clean:
+       rm -f triangle
diff --git a/sample/triangle/test/.gitignore b/sample/triangle/test/.gitignore
new file mode 100644 (file)
index 0000000..c4affcf
--- /dev/null
@@ -0,0 +1,6 @@
+*/1.txt
+*/diff.txt
+*/err.txt
+*/test.log
+*/detail.log
+*/time.log
diff --git a/sample/triangle/test/01_scalene/0.txt b/sample/triangle/test/01_scalene/0.txt
new file mode 100644 (file)
index 0000000..2172c8f
--- /dev/null
@@ -0,0 +1 @@
+scalene triangle
diff --git a/sample/triangle/test/01_scalene/Makefile b/sample/triangle/test/01_scalene/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/01_scalene/cmd b/sample/triangle/test/01_scalene/cmd
new file mode 100755 (executable)
index 0000000..7362956
--- /dev/null
@@ -0,0 +1 @@
+../../triangle 3 4 5
diff --git a/sample/triangle/test/01_scalene/desc.txt b/sample/triangle/test/01_scalene/desc.txt
new file mode 100644 (file)
index 0000000..029a05f
--- /dev/null
@@ -0,0 +1 @@
+有効な不等辺三角形をあらわすテスト・ケース
diff --git a/sample/triangle/test/02_equilateral/0.txt b/sample/triangle/test/02_equilateral/0.txt
new file mode 100644 (file)
index 0000000..6704fca
--- /dev/null
@@ -0,0 +1 @@
+equilateral triangle
diff --git a/sample/triangle/test/02_equilateral/02_equilateral b/sample/triangle/test/02_equilateral/02_equilateral
new file mode 100644 (file)
index 0000000..91ad4aa
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.006s
diff --git a/sample/triangle/test/02_equilateral/Makefile b/sample/triangle/test/02_equilateral/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/02_equilateral/cmd b/sample/triangle/test/02_equilateral/cmd
new file mode 100755 (executable)
index 0000000..2ebe2a3
--- /dev/null
@@ -0,0 +1 @@
+../../triangle 4 4 4
diff --git a/sample/triangle/test/02_equilateral/desc.txt b/sample/triangle/test/02_equilateral/desc.txt
new file mode 100644 (file)
index 0000000..48a23ac
--- /dev/null
@@ -0,0 +1 @@
+有効な正三角形をあらわすテスト・ケース
diff --git a/sample/triangle/test/03_isosceles/0.txt b/sample/triangle/test/03_isosceles/0.txt
new file mode 100644 (file)
index 0000000..4e9e0ff
--- /dev/null
@@ -0,0 +1 @@
+isosceles triangle
diff --git a/sample/triangle/test/03_isosceles/03_isosceles b/sample/triangle/test/03_isosceles/03_isosceles
new file mode 100644 (file)
index 0000000..d6a2a2e
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.004s
diff --git a/sample/triangle/test/03_isosceles/Makefile b/sample/triangle/test/03_isosceles/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/03_isosceles/cmd b/sample/triangle/test/03_isosceles/cmd
new file mode 100755 (executable)
index 0000000..d497a25
--- /dev/null
@@ -0,0 +1 @@
+../../triangle 2 4 4
diff --git a/sample/triangle/test/03_isosceles/desc.txt b/sample/triangle/test/03_isosceles/desc.txt
new file mode 100644 (file)
index 0000000..fe911dc
--- /dev/null
@@ -0,0 +1 @@
+有効な二等辺三角形をあらわすテスト・ケース
diff --git a/sample/triangle/test/04_isosceles_c/0.txt b/sample/triangle/test/04_isosceles_c/0.txt
new file mode 100644 (file)
index 0000000..b7333a3
--- /dev/null
@@ -0,0 +1,3 @@
+isosceles triangle
+isosceles triangle
+isosceles triangle
diff --git a/sample/triangle/test/04_isosceles_c/04_isosceles_c b/sample/triangle/test/04_isosceles_c/04_isosceles_c
new file mode 100644 (file)
index 0000000..a1f9611
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.009s
diff --git a/sample/triangle/test/04_isosceles_c/Makefile b/sample/triangle/test/04_isosceles_c/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/04_isosceles_c/cmd b/sample/triangle/test/04_isosceles_c/cmd
new file mode 100755 (executable)
index 0000000..3cfb153
--- /dev/null
@@ -0,0 +1,3 @@
+../../triangle 3 3 4
+../../triangle 3 4 3
+../../triangle 4 3 3
diff --git a/sample/triangle/test/04_isosceles_c/desc.txt b/sample/triangle/test/04_isosceles_c/desc.txt
new file mode 100644 (file)
index 0000000..34053d0
--- /dev/null
@@ -0,0 +1 @@
+有効な二等辺三角形で2つの等辺を含む3種類の組合せすべてをためすことができる3つのテストケース
diff --git a/sample/triangle/test/05_zero/0.txt b/sample/triangle/test/05_zero/0.txt
new file mode 100644 (file)
index 0000000..e371bce
--- /dev/null
@@ -0,0 +1 @@
+0: invalid argument.
diff --git a/sample/triangle/test/05_zero/05_zero b/sample/triangle/test/05_zero/05_zero
new file mode 100644 (file)
index 0000000..288f919
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.005s
diff --git a/sample/triangle/test/05_zero/Makefile b/sample/triangle/test/05_zero/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/05_zero/cmd b/sample/triangle/test/05_zero/cmd
new file mode 100755 (executable)
index 0000000..c9ab8c0
--- /dev/null
@@ -0,0 +1 @@
+../../triangle 3 4 0
diff --git a/sample/triangle/test/05_zero/desc.txt b/sample/triangle/test/05_zero/desc.txt
new file mode 100644 (file)
index 0000000..4ab99f3
--- /dev/null
@@ -0,0 +1 @@
+1つの辺がゼロの値をもつテスト・ケース
diff --git a/sample/triangle/test/06_minus/0.txt b/sample/triangle/test/06_minus/0.txt
new file mode 100644 (file)
index 0000000..a275577
--- /dev/null
@@ -0,0 +1 @@
+-1: invalid argument.
diff --git a/sample/triangle/test/06_minus/06_minus b/sample/triangle/test/06_minus/06_minus
new file mode 100644 (file)
index 0000000..a072ab3
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.010s
diff --git a/sample/triangle/test/06_minus/Makefile b/sample/triangle/test/06_minus/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/06_minus/cmd b/sample/triangle/test/06_minus/cmd
new file mode 100755 (executable)
index 0000000..665928f
--- /dev/null
@@ -0,0 +1 @@
+../../triangle -1 3 4
diff --git a/sample/triangle/test/06_minus/desc.txt b/sample/triangle/test/06_minus/desc.txt
new file mode 100644 (file)
index 0000000..08d1e83
--- /dev/null
@@ -0,0 +1 @@
+1つの辺が負の値をしめすテスト・ケース
diff --git a/sample/triangle/test/07_line/0.txt b/sample/triangle/test/07_line/0.txt
new file mode 100644 (file)
index 0000000..0456fff
--- /dev/null
@@ -0,0 +1 @@
+not triangle
diff --git a/sample/triangle/test/07_line/07_line b/sample/triangle/test/07_line/07_line
new file mode 100644 (file)
index 0000000..385d704
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.011s
diff --git a/sample/triangle/test/07_line/Makefile b/sample/triangle/test/07_line/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/07_line/cmd b/sample/triangle/test/07_line/cmd
new file mode 100755 (executable)
index 0000000..24eec4b
--- /dev/null
@@ -0,0 +1 @@
+../../triangle 1 2 3
diff --git a/sample/triangle/test/07_line/desc.txt b/sample/triangle/test/07_line/desc.txt
new file mode 100644 (file)
index 0000000..d9c6d52
--- /dev/null
@@ -0,0 +1 @@
+ゼロより大きい3つの整数をもち、そのうち2つの和がそれ以外の1つと等しいようなテスト・ケース
diff --git a/sample/triangle/test/08_lines/0.txt b/sample/triangle/test/08_lines/0.txt
new file mode 100644 (file)
index 0000000..a562ff8
--- /dev/null
@@ -0,0 +1,3 @@
+not triangle
+not triangle
+not triangle
diff --git a/sample/triangle/test/08_lines/08_lines b/sample/triangle/test/08_lines/08_lines
new file mode 100644 (file)
index 0000000..a072ab3
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.010s
diff --git a/sample/triangle/test/08_lines/Makefile b/sample/triangle/test/08_lines/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/08_lines/cmd b/sample/triangle/test/08_lines/cmd
new file mode 100755 (executable)
index 0000000..aea1c3d
--- /dev/null
@@ -0,0 +1,3 @@
+../../triangle 1 2 3
+../../triangle 1 3 2
+../../triangle 3 1 2
diff --git a/sample/triangle/test/08_lines/desc.txt b/sample/triangle/test/08_lines/desc.txt
new file mode 100644 (file)
index 0000000..797413c
--- /dev/null
@@ -0,0 +1 @@
+1辺の長さが他の2辺の長さの和に等しいことを3種類の順列のすべてに対してためすことのできるテスト・ケース
diff --git a/sample/triangle/test/09_less/0.txt b/sample/triangle/test/09_less/0.txt
new file mode 100644 (file)
index 0000000..4552d92
--- /dev/null
@@ -0,0 +1,2 @@
+not triangle
+not triangle
diff --git a/sample/triangle/test/09_less/09_less b/sample/triangle/test/09_less/09_less
new file mode 100644 (file)
index 0000000..326d4ac
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.007s
diff --git a/sample/triangle/test/09_less/Makefile b/sample/triangle/test/09_less/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/09_less/cmd b/sample/triangle/test/09_less/cmd
new file mode 100755 (executable)
index 0000000..acad848
--- /dev/null
@@ -0,0 +1,2 @@
+../../triangle 1 2 4
+../../triangle 12 15 30
diff --git a/sample/triangle/test/09_less/desc.txt b/sample/triangle/test/09_less/desc.txt
new file mode 100644 (file)
index 0000000..c02c0a9
--- /dev/null
@@ -0,0 +1 @@
+ゼロより大きな3つの整数のうち、2つの数の和がそれ以外の1つの数より小さくなるテストケース
diff --git a/sample/triangle/test/10_lesses/0.txt b/sample/triangle/test/10_lesses/0.txt
new file mode 100644 (file)
index 0000000..a562ff8
--- /dev/null
@@ -0,0 +1,3 @@
+not triangle
+not triangle
+not triangle
diff --git a/sample/triangle/test/10_lesses/Makefile b/sample/triangle/test/10_lesses/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/10_lesses/cmd b/sample/triangle/test/10_lesses/cmd
new file mode 100755 (executable)
index 0000000..8056645
--- /dev/null
@@ -0,0 +1,3 @@
+../../triangle 1 2 4
+../../triangle 1 4 2
+../../triangle 4 2 1
diff --git a/sample/triangle/test/10_lesses/desc.txt b/sample/triangle/test/10_lesses/desc.txt
new file mode 100644 (file)
index 0000000..3940632
--- /dev/null
@@ -0,0 +1 @@
+ゼロより大きな3つの整数のうち、2つの数の和がそれ以外の1つの数より小さくなることにおいて、3種類の順列すべてを考慮することのできるテストケース
diff --git a/sample/triangle/test/11_zeroall/0.txt b/sample/triangle/test/11_zeroall/0.txt
new file mode 100644 (file)
index 0000000..e371bce
--- /dev/null
@@ -0,0 +1 @@
+0: invalid argument.
diff --git a/sample/triangle/test/11_zeroall/11_zeroall b/sample/triangle/test/11_zeroall/11_zeroall
new file mode 100644 (file)
index 0000000..288f919
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.005s
diff --git a/sample/triangle/test/11_zeroall/Makefile b/sample/triangle/test/11_zeroall/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/11_zeroall/cmd b/sample/triangle/test/11_zeroall/cmd
new file mode 100755 (executable)
index 0000000..6357f33
--- /dev/null
@@ -0,0 +1 @@
+../../triangle 0 0 0
diff --git a/sample/triangle/test/11_zeroall/desc.txt b/sample/triangle/test/11_zeroall/desc.txt
new file mode 100644 (file)
index 0000000..d4144c8
--- /dev/null
@@ -0,0 +1 @@
+すべての辺がゼロであるテスト・ケース
diff --git a/sample/triangle/test/12_notint/0.txt b/sample/triangle/test/12_notint/0.txt
new file mode 100644 (file)
index 0000000..a891c01
--- /dev/null
@@ -0,0 +1 @@
+3.1: invalid argument.
diff --git a/sample/triangle/test/12_notint/12_notint b/sample/triangle/test/12_notint/12_notint
new file mode 100644 (file)
index 0000000..288f919
--- /dev/null
@@ -0,0 +1 @@
+real   0m0.005s
diff --git a/sample/triangle/test/12_notint/Makefile b/sample/triangle/test/12_notint/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/12_notint/cmd b/sample/triangle/test/12_notint/cmd
new file mode 100755 (executable)
index 0000000..81a9de3
--- /dev/null
@@ -0,0 +1 @@
+../../triangle 3.1 4.5 6.2
diff --git a/sample/triangle/test/12_notint/desc.txt b/sample/triangle/test/12_notint/desc.txt
new file mode 100644 (file)
index 0000000..1a871ee
--- /dev/null
@@ -0,0 +1 @@
+整数でない値をもつテスト・ケース
diff --git a/sample/triangle/test/13_argcnt/0.txt b/sample/triangle/test/13_argcnt/0.txt
new file mode 100644 (file)
index 0000000..67d691b
--- /dev/null
@@ -0,0 +1,2 @@
+too few argument.
+too many argument.
diff --git a/sample/triangle/test/13_argcnt/Makefile b/sample/triangle/test/13_argcnt/Makefile
new file mode 100644 (file)
index 0000000..e38b63c
--- /dev/null
@@ -0,0 +1,3 @@
+include ../Define.mk
+include ../Define_test.mk
+include ../Test.mk
diff --git a/sample/triangle/test/13_argcnt/cmd b/sample/triangle/test/13_argcnt/cmd
new file mode 100755 (executable)
index 0000000..cb98719
--- /dev/null
@@ -0,0 +1,3 @@
+../../triangle 3 4
+../../triangle 3 4 5 6
+
diff --git a/sample/triangle/test/13_argcnt/desc.txt b/sample/triangle/test/13_argcnt/desc.txt
new file mode 100644 (file)
index 0000000..7c9b72e
--- /dev/null
@@ -0,0 +1 @@
+数値の個数が間違っていることをためすテスト・ケース
diff --git a/sample/triangle/test/Define.mk b/sample/triangle/test/Define.mk
new file mode 120000 (symlink)
index 0000000..30e79a4
--- /dev/null
@@ -0,0 +1 @@
+/Users/kazubito/2010_12/autotest.mk/template/Define.mk
\ No newline at end of file
diff --git a/sample/triangle/test/Define_group.mk b/sample/triangle/test/Define_group.mk
new file mode 120000 (symlink)
index 0000000..5efc14d
--- /dev/null
@@ -0,0 +1 @@
+/Users/kazubito/2010_12/autotest.mk/template/Define_group.mk
\ No newline at end of file
diff --git a/sample/triangle/test/Define_test.mk b/sample/triangle/test/Define_test.mk
new file mode 120000 (symlink)
index 0000000..152bd34
--- /dev/null
@@ -0,0 +1 @@
+/Users/kazubito/2010_12/autotest.mk/template/Define_test.mk
\ No newline at end of file
diff --git a/sample/triangle/test/Makefile b/sample/triangle/test/Makefile
new file mode 120000 (symlink)
index 0000000..b78314e
--- /dev/null
@@ -0,0 +1 @@
+/Users/kazubito/2010_12/autotest.mk/template/Group.mk
\ No newline at end of file
diff --git a/sample/triangle/test/Test.mk b/sample/triangle/test/Test.mk
new file mode 120000 (symlink)
index 0000000..bb188bd
--- /dev/null
@@ -0,0 +1 @@
+/Users/kazubito/2010_12/autotest.mk/template/Test.mk
\ No newline at end of file
diff --git a/sample/triangle/triangle.c b/sample/triangle/triangle.c
new file mode 100644 (file)
index 0000000..c38f9a0
--- /dev/null
@@ -0,0 +1,68 @@
+/**********************************************************************
+triangle.c
+引数として指定された3つの整数が三角形の3辺を表すものとし、
+次のうちどれであるかをきめるメッセージを印字する。
+    不等辺三角形(scalene triangle)
+    二等辺三角形(isosceles triangle)
+    正三角形(equilateral triangle)
+
+Glenford J Myers『ソフトウェア・テストの技法』(近代科学社、1980)
+http://www.amazon.co.jp/dp/4764900599
+第1章「自己診断テスト」に記載された「自己診断テスト」の仕様を実装
+**********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+/* #define DEBUG */
+
+int main(int argc, char *argv[])
+{
+    int l[3], i;
+    char *check;
+
+    /* 引数が3以外の場合は、エラー終了 */
+    if(argc != 4) {
+        if(argc < 4) {
+            fprintf(stderr, "too few argument.\n");
+        }
+        else if(argc > 4) {
+            fprintf(stderr, "too many argument.\n");
+        }
+        return -1;
+    }
+    /* 引数が整数かチェック。整数以外の場合はエラー終了 */
+    for(i = 0; i < 3; i++) {
+        l[i] = strtol(argv[i+1], &check, 10);
+        if(*check != '\0' || l[i] <= 0) {
+            fprintf(stderr, "%s: invalid argument.\n", argv[i+1]);
+            #ifdef DEBUG
+            printf("i:%d argv[i+1]:%s check:%s l[%d]:%d\n", i, argv[i+1], check, i, l[i]);
+            #endif
+            return -1;
+        }
+    }
+    #ifdef DEBUG
+    printf("l[0]:%d l[1]:%d l[2]:%d\n", l[0], l[1], l[2]);
+    #endif
+    /* 三角不等式により、三角形になるかを判定 */
+    if(l[0] + l[1] <= l[2] || l[1] + l[2] <= l[0] || l[2] + l[0] <= l[1]) {
+        puts("not triangle");
+    } else {
+        /* 3辺の長さが等しい場合は、正三角形 */
+        if(l[0] == l[1] && l[1] == l[2] && l[2] == l[0]) {
+            puts("equilateral triangle");
+        }
+        /* 2辺の長さが等しい場合は、二等辺三角形 */
+        else if (l[0] == l[1] || l[1] == l[2] || l[2] == l[0]) {
+            puts("isosceles triangle");
+        }
+        /* それ以外の場合は、不等辺三角形 */
+        else {
+            puts("scalene triangle");
+        }
+    }
+    #ifdef DEBUG
+    printf("l[0]:%d l[1]:%d l[2]:%d cosa:%f\n", l[0], l[1], l[2], cosa);
+    #endif
+    return 0;
+}