|
1 | | -test_that("hello() prints correctly with default arguments", { |
| 1 | +test_that("goodbye() prints correctly with default arguments", { |
2 | 2 | # Test the default output |
3 | | - expect_output(hello(), "Hello, world!") |
4 | | - |
| 3 | + expect_output(goodbye(), "Goodbye, world!") |
| 4 | + |
5 | 5 | # Test that the invisible return value is correct |
6 | | - expect_equal(suppressMessages(hello()), "Hello, world!") |
| 6 | + expect_equal(suppressMessages(goodbye()), "Goodbye, world!") |
7 | 7 | }) |
8 | 8 |
|
9 | | -test_that("hello() accepts custom name parameter", { |
| 9 | +test_that("goodbye() accepts custom name parameter", { |
10 | 10 | # Test with a custom name |
11 | | - expect_output(hello("R Users"), "Hello, R Users!") |
| 11 | + expect_output(goodbye("R Users"), "Goodbye, R Users!") |
12 | 12 | }) |
13 | 13 |
|
14 | | -test_that("hello() supports different languages", { |
| 14 | +test_that("goodbye() supports different languages", { |
15 | 15 | # Test English (default) |
16 | | - expect_output(hello(language = "english"), "Hello, world!") |
17 | | - |
| 16 | + expect_output(goodbye(language = "english"), "Goodbye, world!") |
| 17 | + |
18 | 18 | # Test Spanish |
19 | | - expect_output(hello(language = "spanish"), "Hola, world!") |
20 | | - |
| 19 | + expect_output(goodbye(language = "spanish"), "Adiós, world!") |
| 20 | + |
21 | 21 | # Test French |
22 | | - expect_output(hello(language = "french"), "Bonjour, world!") |
23 | | - |
| 22 | + expect_output(goodbye(language = "french"), "Au revoir, world!") |
| 23 | + |
24 | 24 | # Test Portuguese |
25 | | - expect_output(hello(language = "portuguese"), "Olá, world!") |
26 | | - |
| 25 | + expect_output(goodbye(language = "portuguese"), "Adeus, world!") |
| 26 | + |
27 | 27 | # Test unknown language (should default to English) |
28 | | - expect_output(hello(language = "german"), "Hello, world!") |
| 28 | + expect_output(goodbye(language = "german"), "Goodbye, world!") |
29 | 29 | }) |
30 | 30 |
|
31 | | -test_that("hello() correctly handles exclamation parameter", { |
| 31 | +test_that("goodbye() correctly handles exclamation parameter", { |
32 | 32 | # Test with exclamation = TRUE (default) |
33 | | - expect_output(hello(exclamation = TRUE), "Hello, world!") |
34 | | - |
| 33 | + expect_output(goodbye(exclamation = TRUE), "Goodbye, world!") |
| 34 | + |
35 | 35 | # Test with exclamation = FALSE |
36 | | - expect_output(hello(exclamation = FALSE), "Hello, world.") |
| 36 | + expect_output(goodbye(exclamation = FALSE), "Goodbye, world.") |
37 | 37 | }) |
38 | 38 |
|
39 | | -test_that("hello() validates input parameters", { |
| 39 | +test_that("goodbye() validates input parameters", { |
40 | 40 | # Test invalid name parameter |
41 | | - expect_error(hello(name = c("world", "everyone")), "'name' must be a single character string") |
42 | | - expect_error(hello(name = 123), "'name' must be a single character string") |
43 | | - |
| 41 | + expect_error(goodbye(name = c("world", "everyone")), "'name' must be a single character string") |
| 42 | + expect_error(goodbye(name = 123), "'name' must be a single character string") |
| 43 | + |
44 | 44 | # Test invalid language parameter |
45 | | - expect_error(hello(language = c("english", "spanish")), "'language' must be a single character string") |
46 | | - expect_error(hello(language = 123), "'language' must be a single character string") |
47 | | - |
| 45 | + expect_error(goodbye(language = c("english", "spanish")), "'language' must be a single character string") |
| 46 | + expect_error(goodbye(language = 123), "'language' must be a single character string") |
| 47 | + |
48 | 48 | # Test invalid exclamation parameter |
49 | | - expect_error(hello(exclamation = c(TRUE, FALSE)), "'exclamation' must be a single logical value") |
50 | | - expect_error(hello(exclamation = "yes"), "'exclamation' must be a single logical value") |
| 49 | + expect_error(goodbye(exclamation = c(TRUE, FALSE)), "'exclamation' must be a single logical value") |
| 50 | + expect_error(goodbye(exclamation = "yes"), "'exclamation' must be a single logical value") |
51 | 51 | }) |
52 | 52 |
|
53 | | -test_that("hello() works with all combinations of parameters", { |
| 53 | +test_that("goodbye() works with all combinations of parameters", { |
54 | 54 | # Test with all parameters customized |
55 | 55 | expect_output( |
56 | | - hello(name = "friends", language = "spanish", exclamation = FALSE), |
57 | | - "Hola, friends." |
| 56 | + goodbye(name = "friends", language = "spanish", exclamation = FALSE), |
| 57 | + "Adiós, friends." |
58 | 58 | ) |
59 | 59 | }) |
0 commit comments