33#include < fstream>
44#include < sstream>
55
6+ using cmdstan::test::compare_to_stored_output;
67using cmdstan::test::count_matches;
78using cmdstan::test::get_path_separator;
89using cmdstan::test::run_command;
9- using cmdstan::test::run_command_output;
1010
1111TEST (CommandDiagnose, corr_gauss) {
1212 std::string path_separator;
@@ -16,14 +16,11 @@ TEST(CommandDiagnose, corr_gauss) {
1616 + " interface" + path_separator + " example_output"
1717 + path_separator + " corr_gauss_output.csv" ;
1818
19- run_command_output out = run_command (command + " " + csv_file);
19+ auto out = run_command (command + " " + csv_file);
2020 ASSERT_FALSE (out.hasError ) << " \" " << out.command << " \" quit with an error" ;
2121
22- std::ifstream expected_output (
23- " src/test/interface/example_output/corr_gauss.nom" );
24- std::stringstream ss;
25- ss << expected_output.rdbuf ();
26- EXPECT_EQ (1 , count_matches (ss.str (), out.output ));
22+ compare_to_stored_output (out.output ,
23+ " src/test/interface/example_output/corr_gauss.nom" );
2724}
2825
2926TEST (CommandDiagnose, corr_gauss_depth8) {
@@ -34,14 +31,11 @@ TEST(CommandDiagnose, corr_gauss_depth8) {
3431 + " interface" + path_separator + " example_output"
3532 + path_separator + " corr_gauss_output_depth8.csv" ;
3633
37- run_command_output out = run_command (command + " " + csv_file);
34+ auto out = run_command (command + " " + csv_file);
3835 ASSERT_FALSE (out.hasError ) << " \" " << out.command << " \" quit with an error" ;
3936
40- std::ifstream expected_output (
41- " src/test/interface/example_output/corr_gauss_depth8.nom" );
42- std::stringstream ss;
43- ss << expected_output.rdbuf ();
44- EXPECT_EQ (1 , count_matches (ss.str (), out.output ));
37+ compare_to_stored_output (
38+ out.output , " src/test/interface/example_output/corr_gauss_depth8.nom" );
4539}
4640
4741TEST (CommandDiagnose, corr_gauss_depth15) {
@@ -52,14 +46,11 @@ TEST(CommandDiagnose, corr_gauss_depth15) {
5246 + " interface" + path_separator + " example_output"
5347 + path_separator + " corr_gauss_output_depth15.csv" ;
5448
55- run_command_output out = run_command (command + " " + csv_file);
49+ auto out = run_command (command + " " + csv_file);
5650 ASSERT_FALSE (out.hasError ) << " \" " << out.command << " \" quit with an error" ;
5751
58- std::ifstream expected_output (
59- " src/test/interface/example_output/corr_gauss_depth15.nom" );
60- std::stringstream ss;
61- ss << expected_output.rdbuf ();
62- EXPECT_EQ (1 , count_matches (ss.str (), out.output ));
52+ compare_to_stored_output (
53+ out.output , " src/test/interface/example_output/corr_gauss_depth15.nom" );
6354}
6455
6556TEST (CommandDiagnose, eight_schools) {
@@ -70,14 +61,11 @@ TEST(CommandDiagnose, eight_schools) {
7061 + " interface" + path_separator + " example_output"
7162 + path_separator + " eight_schools_output.csv" ;
7263
73- run_command_output out = run_command (command + " " + csv_file);
64+ auto out = run_command (command + " " + csv_file);
7465 ASSERT_FALSE (out.hasError ) << " \" " << out.command << " \" quit with an error" ;
7566
76- std::ifstream expected_output (
77- " src/test/interface/example_output/eight_schools.nom" );
78- std::stringstream ss;
79- ss << expected_output.rdbuf ();
80- EXPECT_EQ (1 , count_matches (ss.str (), out.output ));
67+ compare_to_stored_output (
68+ out.output , " src/test/interface/example_output/eight_schools.nom" );
8169}
8270
8371TEST (CommandDiagnose, mix) {
@@ -88,13 +76,11 @@ TEST(CommandDiagnose, mix) {
8876 + " interface" + path_separator + " example_output"
8977 + path_separator + " mix_output.*" ;
9078
91- run_command_output out = run_command (command + " " + csv_file);
79+ auto out = run_command (command + " " + csv_file);
9280 ASSERT_FALSE (out.hasError ) << " \" " << out.command << " \" quit with an error" ;
9381
94- std::ifstream expected_output (" src/test/interface/example_output/mix.nom" );
95- std::stringstream ss;
96- ss << expected_output.rdbuf ();
97- EXPECT_EQ (1 , count_matches (ss.str (), out.output ));
82+ compare_to_stored_output (out.output ,
83+ " src/test/interface/example_output/mix.nom" );
9884}
9985
10086TEST (CommandDiagnose, divergences) {
@@ -105,11 +91,9 @@ TEST(CommandDiagnose, divergences) {
10591 + " interface" + path_separator + " example_output"
10692 + path_separator + " div_output*.csv" ;
10793
108- run_command_output out = run_command (command + " " + csv_file);
94+ auto out = run_command (command + " " + csv_file);
10995 ASSERT_FALSE (out.hasError ) << " \" " << out.command << " \" quit with an error" ;
11096
111- std::ifstream expected_output (" src/test/interface/example_output/div.nom" );
112- std::stringstream ss;
113- ss << expected_output.rdbuf ();
114- EXPECT_EQ (1 , count_matches (ss.str (), out.output ));
97+ compare_to_stored_output (out.output ,
98+ " src/test/interface/example_output/div.nom" );
11599}
0 commit comments