unit test for atoff()
This commit is contained in:
parent
29df7e2da4
commit
8c53ef3185
|
@ -209,7 +209,7 @@ int efiPow10(int param) {
|
|||
}
|
||||
|
||||
/**
|
||||
* string to float. NaN input is not supported
|
||||
* string to float. NaN input is supported
|
||||
*
|
||||
* @return NAN in case of invalid string
|
||||
* todo: explicit value for error code? probably not, NaN is only returned in case of an error
|
||||
|
@ -220,9 +220,13 @@ float atoff(const char *param) {
|
|||
return (float) NAN;
|
||||
strcpy(todofixthismesswithcopy, param);
|
||||
char *string = todofixthismesswithcopy;
|
||||
if (indexOf(string, 'n') != -1 || indexOf(string, 'N') != -1) {
|
||||
printf("NAN from [%s]\r\n", string);
|
||||
return (float) NAN;
|
||||
}
|
||||
|
||||
// todo: is there a standard function?
|
||||
// todo: create a unit test
|
||||
// unit-tested by 'testMisc()'
|
||||
int dotIndex = indexOf(string, '.');
|
||||
if (dotIndex == -1) {
|
||||
// just an integer
|
||||
|
|
|
@ -61,6 +61,7 @@ extern bool printTriggerDebug;
|
|||
int main(void) {
|
||||
// printTriggerDebug = true;
|
||||
|
||||
testMisc();
|
||||
testDifferentInjectionModes();
|
||||
testPidAutoZigZag();
|
||||
testMissedSpark299();
|
||||
|
@ -76,7 +77,6 @@ int main(void) {
|
|||
testFasterEngineSpinningUp();
|
||||
testInterpolate2d();
|
||||
testGpsParser();
|
||||
testMisc();
|
||||
testFuelMap();
|
||||
testFuelCut();
|
||||
testEngineMath();
|
||||
|
@ -114,7 +114,7 @@ int main(void) {
|
|||
testTriggerDecoder();
|
||||
|
||||
// resizeMap();
|
||||
printf("Success 20180120\r\n");
|
||||
printf("Success 20181120\r\n");
|
||||
printAllTriggers();
|
||||
// printConvertedTable();
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
@ -407,6 +407,10 @@ void testMisc(void) {
|
|||
assertTrue(strEqual("ab", efiTrim(buff)));
|
||||
|
||||
|
||||
{
|
||||
float v = atoff("1.0");
|
||||
assertEqualsM("atoff", 1.0, v);
|
||||
}
|
||||
{
|
||||
float v = atoff("nan");
|
||||
assertTrueM("NaN atoff", cisnan(v));
|
||||
|
|
Loading…
Reference in New Issue