-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
128 changed files
with
9,349 additions
and
21,227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
wheel ~= 0.43 | ||
twine ~= 5.0 | ||
twine ~= 5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
# Project configuration | ||
set(PROJECT_NAME Unittesting) | ||
project(${PROJECT_NAME}) | ||
# * PROJECT_SOURCE_DIR - Top level source directory for the project | ||
# * PROJECT_BINARY_DIR - Full path to build directory for project | ||
|
||
# Compiler flags | ||
set(CMAKE_CXX_FLAGS "-g -Wall") | ||
set(CMAKE_CXX_STANDARD 20) | ||
|
||
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.[ch]pp) | ||
|
||
add_library(app STATIC ${SRC_FILES}) | ||
target_include_directories(app PUBLIC ${PROJECT_SOURCE_DIR}/src) | ||
|
||
# GoogleTest | ||
add_subdirectory(./lib/googletest) | ||
|
||
######################################## | ||
# Test files | ||
######################################## | ||
file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.[ch]pp) | ||
|
||
######################################## | ||
# Unit Tests | ||
######################################## | ||
add_executable(unit_tests ${TEST_SRC_FILES}) | ||
target_link_libraries(unit_tests app gtest_main) | ||
|
||
|
||
enable_testing() | ||
include(GoogleTest) | ||
gtest_discover_tests(unit_tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "Counter.hpp" | ||
|
||
int Counter::Value() { | ||
return _value; | ||
} | ||
|
||
int Counter::Increment() { | ||
return _value++; | ||
} | ||
|
||
int Counter::Decrement() { | ||
return _value--; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef COUNTER_H_ | ||
#define COUNTER_H_ | ||
|
||
class Counter { | ||
private: | ||
int _value; | ||
|
||
public: | ||
Counter(int value = 0) : _value { value } {} | ||
|
||
int Value(); | ||
int Increment(); | ||
int Decrement(); | ||
}; | ||
|
||
#endif // COUNTER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "Counter.hpp" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace { | ||
|
||
TEST(Counter, Init) { | ||
Counter c0 { 0 }; | ||
Counter c1 { 1 }; | ||
EXPECT_EQ(0, c0.Value()); | ||
EXPECT_EQ(1, c1.Value()); | ||
} | ||
|
||
TEST(Counter, Increment) { | ||
Counter c { 0 }; | ||
EXPECT_EQ(0, c.Increment()); | ||
EXPECT_EQ(1, c.Value()); | ||
} | ||
|
||
TEST(Counter, Decrement) { | ||
Counter c { 1 }; | ||
EXPECT_EQ(1, c.Decrement()); | ||
EXPECT_EQ(0, c.Value()); | ||
} | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<project name="MyProject" default="junit" basedir="."> | ||
<description> | ||
simple example build file | ||
</description> | ||
|
||
<property name="src" location="src" /> | ||
<property name="test" location="test" /> | ||
<property name="build" location="build" /> | ||
|
||
<target name="init"> | ||
<tstamp /> | ||
<mkdir dir="${build}" /> | ||
</target> | ||
|
||
<target name="compile" depends="init" description="compile the source"> | ||
<javac destdir="${build}" includeantruntime="false"> | ||
<src path="${src}" /> | ||
<src path="${test}" /> | ||
<classpath> | ||
<pathelement location="/usr/share/gradle-8.7/lib/junit-4.13.2.jar"/> | ||
</classpath> | ||
</javac> | ||
</target> | ||
|
||
<target name="junit" depends="compile"> | ||
<junit haltonerror="true" printsummary="true"> | ||
<classpath> | ||
<pathelement location="/usr/share/gradle-8.7/lib/junit-4.13.2.jar"/> | ||
<pathelement location="/usr/share/gradle-8.7/lib/hamcrest-core-1.3.jar"/> | ||
<pathelement location="${build}"/> | ||
</classpath> | ||
<formatter type="xml"/> | ||
<batchtest fork="false" todir="${build}"> | ||
<fileset dir="${test}"> | ||
<include name="**/*Test.java"/> | ||
<include name="**/AllTests.java"/> | ||
</fileset> | ||
</batchtest> | ||
</junit> | ||
</target> | ||
|
||
<target name="clean" description="clean up"> | ||
<delete dir="${build}" /> | ||
<delete dir="${dist}" /> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package my.pack; | ||
|
||
public class MyClass { | ||
boolean returnTrue() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package my.pack; | ||
|
||
public class OtherClass { | ||
int returnThree() { | ||
return 3; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package my; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
import org.junit.runners.Suite.SuiteClasses; | ||
|
||
@RunWith(Suite.class) | ||
@SuiteClasses({ my.pack.AllTests.class }) | ||
public class AllTests { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package my.pack; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
import org.junit.runners.Suite.SuiteClasses; | ||
|
||
@RunWith(Suite.class) | ||
@SuiteClasses({ MyClassTest.class, OtherClassTest.class }) | ||
public class AllTests { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package my.pack; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Test; | ||
|
||
public class MyClassTest { | ||
|
||
@Test | ||
public void testReturnTrue() { | ||
assertTrue(new MyClass().returnTrue()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package my.pack; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Test; | ||
|
||
public class OtherClassTest { | ||
|
||
@Test | ||
public void testReturnThree() { | ||
assertEquals(3, new OtherClass().returnThree()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from unittest import TestCase | ||
|
||
|
||
class A: | ||
_value: int | ||
|
||
def __init__(self, value: int = 0): | ||
self._value = value | ||
|
||
@property | ||
def Value(self) -> int: | ||
return self._value | ||
|
||
@Value.setter | ||
def Value(self, value: int): | ||
self._value = value | ||
|
||
|
||
class Instantiation(TestCase): | ||
def test_NoParameter(self): | ||
a = A() | ||
|
||
self.assertEqual(0, a.Value) | ||
|
||
def test_Parameter(self): | ||
a = A(5) | ||
|
||
self.assertEqual(5, a.Value) | ||
|
||
|
||
class Properties(TestCase): | ||
def test_Getter(self): | ||
a = A(10) | ||
|
||
self.assertEqual(10, a.Value) | ||
|
||
def test_Setter(self): | ||
a = A(15) | ||
self.assertEqual(15, a.Value) | ||
|
||
a.Value = 20 | ||
self.assertEqual(20, a.Value) |
Oops, something went wrong.