xo-unit: docs: + example programs
This commit is contained in:
parent
d9868870e4
commit
0d9fd75b0c
8 changed files with 103 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ xo_toplevel_compile_options()
|
|||
# ----------------------------------------------------------------
|
||||
|
||||
#add_subdirectory(src/unit)
|
||||
add_subdirectory(example)
|
||||
add_subdirectory(utest)
|
||||
add_subdirectory(docs)
|
||||
|
||||
|
|
|
|||
3
example/CMakeLists.txt
Normal file
3
example/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
add_subdirectory(ex1)
|
||||
add_subdirectory(ex2)
|
||||
add_subdirectory(ex3)
|
||||
14
example/ex1/CMakeLists.txt
Normal file
14
example/ex1/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# xo-unit/example/ex1/CMakeLists.txt
|
||||
|
||||
set(SELF_EXE xo_unit_ex1)
|
||||
set(SELF_SRCS ex1.cpp)
|
||||
|
||||
add_executable(${SELF_EXE} ${SELF_SRCS})
|
||||
xo_include_options2(${SELF_EXE})
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# dependencies..
|
||||
|
||||
xo_self_dependency(${SELF_EXE} xo_unit)
|
||||
|
||||
# end CMakeLists.txt
|
||||
18
example/ex1/ex1.cpp
Normal file
18
example/ex1/ex1.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/** @file ex1.cpp **/
|
||||
|
||||
#include "xo/unit/quantity.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main () {
|
||||
namespace qty = xo::obs::qty;
|
||||
using namespace std;
|
||||
|
||||
auto t = qty::milliseconds(10);
|
||||
auto m = qty::kilograms(2.5);
|
||||
auto a = m / (t*t);
|
||||
|
||||
cerr << "t: " << t << ", m: " << m << ", m.t^-2: " << a << endl;
|
||||
}
|
||||
|
||||
/** end ex1.cpp **/
|
||||
14
example/ex2/CMakeLists.txt
Normal file
14
example/ex2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# xo-unit/example/ex2/CMakeLists.txt
|
||||
|
||||
set(SELF_EXE xo_unit_ex2)
|
||||
set(SELF_SRCS ex2.cpp)
|
||||
|
||||
add_executable(${SELF_EXE} ${SELF_SRCS})
|
||||
xo_include_options2(${SELF_EXE})
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# dependencies..
|
||||
|
||||
xo_self_dependency(${SELF_EXE} xo_unit)
|
||||
|
||||
# end CMakeLists.txt
|
||||
20
example/ex2/ex2.cpp
Normal file
20
example/ex2/ex2.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/** @file ex2.cpp **/
|
||||
|
||||
#include "xo/unit/quantity.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main () {
|
||||
namespace u = xo::obs::units;
|
||||
namespace qty = xo::obs::qty;
|
||||
using xo::obs::quantity;
|
||||
using namespace std;
|
||||
|
||||
quantity<u::second> t = qty::milliseconds(10);
|
||||
quantity<u::gram> m = qty::kilograms(2.5);
|
||||
auto a = m / (t*t);
|
||||
|
||||
cerr << "t: " << t << ", m: " << m << ", m.t^-2: " << a << endl;
|
||||
}
|
||||
|
||||
/** end ex2.cpp **/
|
||||
14
example/ex3/CMakeLists.txt
Normal file
14
example/ex3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# xo-unit/example/ex3/CMakeLists.txt
|
||||
|
||||
set(SELF_EXE xo_unit_ex3)
|
||||
set(SELF_SRCS ex3.cpp)
|
||||
|
||||
add_executable(${SELF_EXE} ${SELF_SRCS})
|
||||
xo_include_options2(${SELF_EXE})
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# dependencies..
|
||||
|
||||
xo_self_dependency(${SELF_EXE} xo_unit)
|
||||
|
||||
# end CMakeLists.txt
|
||||
19
example/ex3/ex3.cpp
Normal file
19
example/ex3/ex3.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/** @file ex3.cpp **/
|
||||
|
||||
#include "xo/unit/quantity.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main () {
|
||||
namespace u = xo::obs::units;
|
||||
namespace qty = xo::obs::qty;
|
||||
using xo::obs::quantity;
|
||||
using namespace std;
|
||||
|
||||
auto t1 = qty::milliseconds(1);
|
||||
auto t2 = qty::minutes(1);
|
||||
|
||||
cerr << "t1: " << t1 << ", t2: " << t2 << ", t1*t2: " << t1*t2 << endl;
|
||||
}
|
||||
|
||||
/** end ex3.cpp **/
|
||||
Loading…
Add table
Add a link
Reference in a new issue