add typetest.cpp

master
neingeist 11 years ago
parent 04851b7e5f
commit ae7f6839cc

@ -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} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Weffc++") 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(auto_ptr auto_ptr.cpp)
add_executable(unique_ptr unique_ptr.cpp) add_executable(unique_ptr unique_ptr.cpp)

@ -0,0 +1,33 @@
#include <cassert>
#include <iostream>
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;
}
Loading…
Cancel
Save