diff --git a/CMakeLists.txt b/CMakeLists.txt index fe9eea8..d910bfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,5 +3,6 @@ set(CMAKE_CXX_COMPILER "clang++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Weffc++") +add_executable(typetest typetest.cpp) add_executable(auto_ptr auto_ptr.cpp) add_executable(unique_ptr unique_ptr.cpp) diff --git a/typetest.cpp b/typetest.cpp new file mode 100644 index 0000000..c7cc2b7 --- /dev/null +++ b/typetest.cpp @@ -0,0 +1,33 @@ +#include +#include + +int main() +{ + int someInteger = 256; + short someShort; + long someLong; + float someFloat; + double someDouble; + + someInteger++; + assert(someInteger == 257); + + someInteger *= 2; + assert(someInteger == 514); + + someShort = (short) someInteger; + assert((int) someShort == 514); // (short more than 1 byte) + + someLong = someShort * 10000; + assert(someLong == 5140000l); + + someFloat = someLong * 0.785; + assert(abs(someFloat - 4034900.000) < 0.0001); + + someDouble = (double)someFloat / 100000; + assert(abs(someDouble - 40.349) < 0.0001); + + std::cout << someDouble << std::endl; + + return 0; +}