-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.rb
More file actions
40 lines (35 loc) · 1.42 KB
/
test.rb
File metadata and controls
40 lines (35 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'minitest/autorun'
require "open3"
class TestExpand < Minitest::Test
CFLAGS = "-std=c99 -Wall"
def test_assert_success
`cc #{CFLAGS} assert.c test/test_assert_success.c -o assert_success.out`
stdout_str, stderr_str, status = Open3.capture3("./assert_success.out")
assert_equal "", stdout_str
assert_equal 0, status.exitstatus
assert_equal "", stderr_str
end
def test_assert_fail
`cc #{CFLAGS} assert.c test/test_assert_fail.c -o assert_fail.out`
stdout_str, stderr_str, status = Open3.capture3("./assert_fail.out")
assert_equal "", stdout_str
assert_equal false, status.exited?
assert_equal "Assertion failed: (1 == 2), in function: assert2, file: test/test_assert_fail.c, line: 7.\n",
stderr_str
end
def test_assert_ndebug
`cc #{CFLAGS} assert.c test/test_assert_ndebug.c -o assert_ndebug.out`
stdout_str, stderr_str, status = Open3.capture3("./assert_ndebug.out")
assert_equal "", stdout_str
assert_equal 0, status.exitstatus
assert_equal "", stderr_str
end
def test_assert_multi_include
`cc #{CFLAGS} assert.c test/test_multi_include.c -o assert_multi_include.out`
stdout_str, stderr_str, status = Open3.capture3("./assert_multi_include.out")
assert_equal "", stdout_str
assert_equal false, status.exited?
assert_equal "Assertion failed: (1 == 2), in function: assert2, file: test/test_multi_include.c, line: 8.\n",
stderr_str
end
end