ICT290 / test / exampleTest.cpp
exampleTest.cpp
Raw
#include "gtest/gtest.h"

// source files are accessible like this
#include <glIncludes.h>

#include <ShaysWorld/main.h>

#include <exception>
#include <iostream>

// first - test suite (like the overall component of the program you're testing)
// second - test name (like the specific test being done
TEST(ShaysWorldExampleTest, TestDeleteImageFromMemory) {
    // you can call functions from source like normal
    // ShaysWorld::DeleteImageFromMemory(nullptr);

    // use GTest assertons
    // if they fail, you get nice verbose info about what failed and why
    // eg. ASSERT_EQ failed, 1 != 2
    // eg. ASSERT_TRUE failed, got false
    // ASSERT_EQ and NO_THROW are most verbose, so try to use them before TRUE
    // and FALSE, makes debugging easier later on Better to over-test than
    // under-test, gives better output and makes it easier to find the specific
    // issue with code
    ASSERT_ANY_THROW(throw std::runtime_error("This was expected"));
    ASSERT_TRUE(true);
    ASSERT_FALSE(false);
    ASSERT_EQ(0.5f, 1.0f / 2.0f);
    ASSERT_NO_THROW(std::cout << "yo\n");
}