1 /** 2 Copyright: Copyright (c) 2017, Joakim Brännström. All rights reserved. 3 License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 */ 6 module dextool_test.gtest_integration; 7 8 import dextool_test.utility; 9 10 // dfmt off 11 12 @("shall pretty print the struct") 13 unittest { 14 mixin(EnvSetup(globalTestdir)); 15 makeDextool(testEnv) 16 .addInputArg(pluginTestData ~ "stage_3/pretty_print.hpp") 17 .run; 18 dextool_test.makeCompile(testEnv, "g++") 19 .addInclude(pluginTestData ~ "stage_3") 20 .addArg(pluginTestData ~ "stage_3/pretty_print.cpp") 21 .addFileFromOutdir("test_double_fused_gtest.cpp") 22 .addGtestArgs 23 .outputToDefaultBinary 24 .run; 25 makeCommand(testEnv, defaultBinary) 26 .run; 27 } 28 29 @("shall generate pretty printers for structs in a namespace") 30 unittest { 31 mixin(EnvSetup(globalTestdir)); 32 makeDextool(testEnv) 33 .addInputArg(pluginTestData ~ "stage_3/test_pretty_print_in_ns.hpp") 34 .run; 35 dextool_test.makeCompile(testEnv, "g++") 36 .addInclude(pluginTestData ~ "stage_3") 37 .addArg(pluginTestData ~ "stage_3/test_pretty_print_in_ns.cpp") 38 .addFileFromOutdir("test_double_fused_gtest.cpp") 39 .addGtestArgs 40 .outputToDefaultBinary 41 .run; 42 auto r = makeCommand(testEnv, defaultBinary) 43 .run; 44 45 r.stdout.sliceContains([ 46 "Expected: a", 47 "Which is: x:1", 48 "To be equal to: b", 49 "Which is: x:2", 50 ]); 51 52 r.stdout.sliceContains([ 53 "Expected: a", 54 "Which is: y:1", 55 "To be equal to: b", 56 "Which is: y:2" 57 ]); 58 } 59 60 @("shall generate pretty printers for structs that have public members") 61 unittest { 62 mixin(EnvSetup(globalTestdir)); 63 makeDextool(testEnv) 64 .addInputArg(pluginTestData ~ "stage_1/test_pretty_print_generator.hpp") 65 .run; 66 67 exists(testEnv.outdir ~ "test_double_pod_empty_gtest.hpp").shouldBeFalse; 68 exists(testEnv.outdir ~ "test_double_pod_only_private_gtest.hpp").shouldBeFalse; 69 exists(testEnv.outdir ~ "test_double_pod_only_protected_gtest.hpp").shouldBeFalse; 70 71 makeCompile(testEnv, pluginTestData ~ "stage_1") 72 .addFileFromOutdir("test_double_fused_gtest.cpp") 73 .addGtestArgs 74 .run; 75 }