Commit Graph
40 Commits
Author SHA1 Message Date
Mateusz Pusz 645570ff57 Library updated to the latest cmake common tools 2020-01-31 17:02:27 +01:00
Mateusz Pusz 876c2ac426 thou used as a primary unit in a fmt unit test 2020-01-14 12:59:37 +01:00
Andy Little 024f5a9c83 change const order
move in,ft,fathom,ft2,ft3,mph from us to international namespace
TODO distinguish units with different names for same values
2020-01-12 21:34:36 +01:00
Mateusz Pusz a01c811f5f Square and cubic UDLs renamed 2020-01-09 10:03:41 +01:00
Mateusz Pusz 159e2c1c02 ratio_text improved to omit den == 1 for exp != 0 2019-12-29 17:19:55 +01:00
Mateusz Pusz e7f37e4e33 CGS fmt tests added 2019-12-29 17:06:03 +01:00
Mateusz Pusz 17e6b0d75d Small refactoring of new ratio (resolves #14) 2019-12-28 18:59:53 +01:00
Oliver Schönrock 0ad78fe753 small changes based on code review 2019-12-28 17:59:47 +01:00
Oliver Schönrock 509b6c9653 implementing ratio<num,den,exp> which replaces ratio<num,den>
https://github.com/mpusz/units/issues/14

This "works", as in it passes all static and runtime tests.
However quite a few of the tests have been "modified" to make them pass. Whether
this is legitimate is debatable and should be the source of some thought /
discussion.

1. many of the static tests and some of the runtime tests have had the input
ratios of the tests modified in the following way. eg ratio<3,1000> =>
ratio<3,1,-3>. ie they have been "canonicalised".

There are obviously an infinite number of ratios which represent the same
rational number. The way `ratio` is implemented it always moves as "many powers
of 10" from the `num` and `den` into the `exp` and that makes the `canonical`
ratio.

Because these are all "types" and the lib uses is_same all over the place, only
exact matches will be `is_same`. ie ratio<300,4,0> !is_same ratio<3,4,2> (the
latter is the canonical ratio). This is perhaps fine for tests in the devlopment
phase, but there may be a need for "more forgiving" comparison / concept of
value equality. One such comparison which compares den,num,exp after
canonicalisation is the constexpr function `same` as defined at top of
`ratio_test.cpp`. We may need to expose this and perhaps add even more soft
comparisions.

2. In the runtime tests it is "subjective" how some resukts should be
printed. There is the question of "how exactly to format certain ratios". eg
omit denominators of "1" and exponents of "0". However before even addressing
these in detail a decision needs to be made about the general form of
"non-floating-point-converted" ratios which do not map exactly to a "Symbol
prefix".

Arguably these are "relatively ugly" whatever we do, so we could just
go for an easily canonicalised form. An example is:

-        CHECK(stream.str() == "10 [1/60]W");
+        CHECK(stream.str() == "10 [1/6 x 10⁻¹]W");

Which of thses is "better"? Is there a "third", better form?  It's not obvious.

My opnion is: Both of 1&2 are fine for now, unless we think they go down the
wrong avenue, and can be "perfected later"? ie we can expose a softer version of
ratio based equality, and decide on canonical way of printing ratios (as far as
that is actually a very useful output form, compared with decimal, scientific or
engineering notation).
2019-12-28 17:59:47 +01:00
Mateusz Pusz 69974f82cd Floating-point UDLs removed from fmt_test 2019-12-23 13:23:23 +01:00
Mateusz Pusz 758c05ea15 quantity_cast fmt tests added 2019-12-23 13:22:37 +01:00
Mateusz Pusz 80a13b1a94 US system isolated from SI 2019-12-17 12:29:19 +01:00
Mateusz Pusz 6596c15238 scaled_unit template parameters order fixed (sorry Oliver) 2019-12-14 21:16:15 +01:00
Mateusz Pusz bc1901f4f0 Text formatting enabled + directory tree refactoring 2019-12-11 08:07:13 +01:00
Mateusz Pusz 65ea59edbb digital_information_test renamed to workaround the issue with vscode test explorer 2019-11-28 23:01:06 +01:00
Mateusz Pusz ff656620e9 fmt support for sign added 2019-11-12 19:46:15 +01:00
Mateusz Pusz 6d9cb8197f fmt fill and allign support added 2019-11-12 16:55:11 +01:00
Mateusz Pusz 83edb46de8 coherent_derived_unit symbol synthetizing fixed 2019-11-10 19:51:25 +01:00
Mateusz Pusz 9a96235e6c Synthesizing unit symbols in deduced_derived_unit support added (resolves #13) 2019-11-10 16:55:16 +00:00
Mateusz Pusz 03e3691d47 More text output tests added 2019-11-09 21:01:37 +00:00
Mateusz Pusz 0125bd7762 Derived unit factory helpers refactored 2019-11-08 16:51:45 +00:00
Mateusz Pusz c6d2002ebd More fmt unit tests added 2019-11-06 22:45:45 +00:00
Mateusz Pusz 615c80e231 Tabulator and new line format string unit tests added 2019-11-06 21:52:48 +00:00
Mateusz Pusz 1b312b1102 fmt support added 2019-11-06 16:50:34 +00:00
Mateusz Pusz b5b2c54fe8 Basic std::fmt support added 2019-11-05 20:05:11 +00:00
Mateusz Pusz 4d3e4aa1fc Surface tension added 2019-11-04 06:46:53 +00:00
Mateusz Pusz 91bcfedf1e Deduced units symbols refactoring started 2019-11-04 06:45:56 +00:00
Mateusz Pusz 8543ab65d1 pow<0> support added 2019-10-19 20:51:20 +02:00
Mateusz Pusz 53720c82b8 fmt support started 2019-10-18 23:50:43 +02:00
Mateusz Pusz 987ab86439 Added support for prefixes of non-coherent units 2019-10-18 22:36:57 +02:00
Mateusz Pusz 718e56082a Prefix definition reworked 2019-10-18 21:34:50 +02:00
Mateusz Pusz b864461636 Prefixed units support redesigned 2019-10-18 15:34:46 +02:00
Mateusz Pusz f147da202e Multiply symbot in a printed unit changed to '⋅' 2019-10-17 12:44:39 +02:00
Mateusz Pusz 3e30c779a6 coherent_derived_unit and custom prefixes support added 2019-10-17 10:16:44 +02:00
Mateusz Pusz 9a9abca81d Text output support added for quantity 2019-10-16 17:04:41 +02:00
Mateusz Pusz c3c5a740d9 derived_units now stores a type provided as a template parameter rather than its value 2019-10-15 15:20:37 +02:00
Mateusz Pusz 7e31dfe37e Name renamed to symbol in a derived_unit 2019-10-15 11:47:36 +02:00
Mateusz Pusz b889c81cb9 Short name added to derived unit definition 2019-10-15 11:32:59 +02:00
Mateusz Pusz 527927e905 pow<3>() check added to the math uni test 2019-10-15 11:27:39 +02:00
Mateusz Pusz 3475f5193e Catch2 support added (resolves #8) 2019-10-14 10:53:02 +02:00