Deze tekst zal je in enkele stappen tonen hoe je het TicTacToe programma (te gebruiken in het Project Software Engineering) kunt laden in CLion. Het voorbeeld start van de eerste versie TicTacToe10 maar daaropvolgende versies zouden op een gelijkaardige manier geladen moeten worden.
Doel: Het ultieme doel van dit laadproces is het TicTacToe project op een dusdanige manier op te zetten dat er twee configuraties zijn ("Build Configurations"): (a) een "Release" versie waarin alleen het hoogstnaadzakelijke voor een demonstratie aan de spreekwoordelijke eindgebruiker; (b) een "Debug" versie met extraatjes die we gebruiken tijdens het ontwikkelproces (tests, debug, ...).
> ./configure > cmake . > make
./gtest: include lib ./gtest/include: gtest ./gtest/include/gtest: ... gtest.h ... ./gtest/lib: libgtest.a libgtest_main.a
./src: TicTacToe.cpp TicTacToe.h TicTacToeMain.cpp TicTacToeTests.cpp
Stap 4 - Test en Demonstratie run
**** Build of configuration Debug for project TicTacToe **** make all Building file: ../src/TicTacToe.cpp Invoking: GCC C++ Compiler g++ -I../../../workspace/gtest/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TicTacToe.d" -MT"src/TicTacToe.d" -o "src/TicTacToe.o" "../src/TicTacToe.cpp" Finished building: ../src/TicTacToe.cpp Building file: ../src/TicTacToeTests.cpp Invoking: GCC C++ Compiler g++ -I../../../workspace/gtest/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TicTacToeTests.d" -MT"src/TicTacToeTests.d" -o "src/TicTacToeTests.o" "../src/TicTacToeTests.cpp" Finished building: ../src/TicTacToeTests.cpp Building target: TicTacToe Invoking: MacOS X C++ Linker g++ -L../../../workspace/gtest/lib -o "TicTacToe" ./src/TicTacToe.o ./src/TicTacToeTests.o -lgtest -lgtest_main Finished building target: TicTacToe **** Build Finished ****
[==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from TicTactToeTest [ RUN ] TicTactToeTest.DefaultConstructor [ OK ] TicTactToeTest.DefaultConstructor (0 ms) [ RUN ] TicTactToeTest.HappyDay [ OK ] TicTactToeTest.HappyDay (0 ms) [----------] 2 tests from TicTactToeTest (0 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (0 ms total) [ PASSED ] 2 tests.
Alle tests zijn [PASSED] ... oef !
**** Build of configuration Release for project TicTacToe **** make all Building file: ../src/TicTacToe.cpp Invoking: GCC C++ Compiler g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TicTacToe.d" -MT"src/TicTacToe.d" -o "src/TicTacToe.o" "../src/TicTacToe.cpp" Finished building: ../src/TicTacToe.cpp Building file: ../src/TicTacToeMain.cpp Invoking: GCC C++ Compiler g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TicTacToeMain.d" -MT"src/TicTacToeMain.d" -o "src/TicTacToeMain.o" "../src/TicTacToeMain.cpp" Finished building: ../src/TicTacToeMain.cpp Building target: TicTacToe Invoking: MacOS X C++ Linker g++ -o "TicTacToe" ./src/TicTacToe.o ./src/TicTacToeMain.o Finished building target: TicTacToe **** Build Finished ****
Ook nu worden alle .cpp bestanden gecompileerd naar hun respectievelijk .o bestanden; maar nu zonder de -I optie. Ook tijdens het linken wordt de -L optie en de bibliotheken -lgtest en -lgtest_main niet gebruikt.
START: ttt.nrOfMoves() = 0 END: ttt.nrOfMoves() = 9
Dus zowel de Debug configuratie (= tests) als de Release configuratie (= demonstratie) geven een verschillend resultaat.