rdkcentral / ut-core

Unit Test - Core Framework
Apache License 2.0
4 stars 0 forks source link

i:94:ut-core: Generate C++ Wrapper for main functionality #94

Closed Ulrond closed 3 weeks ago

Ulrond commented 2 months ago

Goals

Key Deliverables

Additional Notes (Optional)

This gtest test should work 100% through the ut-core C++ framework as an example

#include "gtest/gtest.h"  // Include the gtest header

// Function to be tested
int add(int a, int b) {
    return a + b;
}

// Test case for the add function
TEST(MathTest, AddTest) {
    EXPECT_EQ(add(2, 3), 5);  // Test if 2 + 3 = 5
    EXPECT_EQ(add(-1, 1), 0); // Test if -1 + 1 = 0
    EXPECT_NE(add(10, 5), 14); // Test if 10 + 5 is NOT equal to 14 
}

int main(int argc, char **argv) {
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS(); // Execute all defined tests
}

But to enable extended features, we would support this upgrade to the test

#include "ut-core-cpp.h"  // Include the framework header

// Function to be tested
int add(int a, int b) {
    return a + b;
}

// Test case for the add function
TEST(MathTest, AddTest) {
    EXPECT_EQ(add(2, 3), 5);  // Test if 2 + 3 = 5
    EXPECT_EQ(add(-1, 1), 0); // Test if -1 + 1 = 0
    EXPECT_NE(add(10, 5), 14); // Test if 10 + 5 is NOT equal to 14 
}

int main(int argc, char **argv) {
    ut-core::Init(&argc, argv);
    return RUN_ALL_TESTS(); // Execute all defined tests
}
Ulrond commented 3 weeks ago

work being completed as part of Issue #11 and PR #102