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
|
* @return NAN in case of invalid string
|
||||||
* todo: explicit value for error code? probably not, NaN is only returned in case of an error
|
* 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;
|
return (float) NAN;
|
||||||
strcpy(todofixthismesswithcopy, param);
|
strcpy(todofixthismesswithcopy, param);
|
||||||
char *string = todofixthismesswithcopy;
|
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: is there a standard function?
|
||||||
// todo: create a unit test
|
// unit-tested by 'testMisc()'
|
||||||
int dotIndex = indexOf(string, '.');
|
int dotIndex = indexOf(string, '.');
|
||||||
if (dotIndex == -1) {
|
if (dotIndex == -1) {
|
||||||
// just an integer
|
// just an integer
|
||||||
|
|
|
@ -61,6 +61,7 @@ extern bool printTriggerDebug;
|
||||||
int main(void) {
|
int main(void) {
|
||||||
// printTriggerDebug = true;
|
// printTriggerDebug = true;
|
||||||
|
|
||||||
|
testMisc();
|
||||||
testDifferentInjectionModes();
|
testDifferentInjectionModes();
|
||||||
testPidAutoZigZag();
|
testPidAutoZigZag();
|
||||||
testMissedSpark299();
|
testMissedSpark299();
|
||||||
|
@ -76,7 +77,6 @@ int main(void) {
|
||||||
testFasterEngineSpinningUp();
|
testFasterEngineSpinningUp();
|
||||||
testInterpolate2d();
|
testInterpolate2d();
|
||||||
testGpsParser();
|
testGpsParser();
|
||||||
testMisc();
|
|
||||||
testFuelMap();
|
testFuelMap();
|
||||||
testFuelCut();
|
testFuelCut();
|
||||||
testEngineMath();
|
testEngineMath();
|
||||||
|
@ -114,7 +114,7 @@ int main(void) {
|
||||||
testTriggerDecoder();
|
testTriggerDecoder();
|
||||||
|
|
||||||
// resizeMap();
|
// resizeMap();
|
||||||
printf("Success 20180120\r\n");
|
printf("Success 20181120\r\n");
|
||||||
printAllTriggers();
|
printAllTriggers();
|
||||||
// printConvertedTable();
|
// printConvertedTable();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
@ -407,6 +407,10 @@ void testMisc(void) {
|
||||||
assertTrue(strEqual("ab", efiTrim(buff)));
|
assertTrue(strEqual("ab", efiTrim(buff)));
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
float v = atoff("1.0");
|
||||||
|
assertEqualsM("atoff", 1.0, v);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
float v = atoff("nan");
|
float v = atoff("nan");
|
||||||
assertTrueM("NaN atoff", cisnan(v));
|
assertTrueM("NaN atoff", cisnan(v));
|
||||||
|
|
Loading…
Reference in New Issue