本文整理汇总了C++中Converter::convertTemperature方法的典型用法代码示例。如果您正苦于以下问题:C++ Converter::convertTemperature方法的具体用法?C++ Converter::convertTemperature怎么用?C++ Converter::convertTemperature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::convertTemperature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unittest
void unittest () {
unsigned short utCount = 10;
unsigned short utPassed = 0;
cout << "\nSTARTING UNIT TEST\n\n";
Converter c;
try {
btassert<bool>(static_cast<int>(c.convertTemperature(32, 'M')) == 0);
cout << "Passed TEST 1: convertTemperature(32, 'M')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 1 convertTemperature(32, 'M') #\n";
}
try {
btassert<bool>(static_cast<int>(c.convertTemperature(212, 'M')) == 100);
cout << "Passed TEST 2: convertTemperature(212, 'M')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 2 convertTemperature(212, 'M') #\n";
}
try {
btassert<bool>(static_cast<int>(c.convertTemperature(98.6, 'M')) == 37);
cout << "Passed TEST 3: convertTemperature(98.6, 'M')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 3 convertTemperature(98.6, 'M') #\n";
}
try {
btassert<bool>(static_cast<int>(c.convertTemperature(0, 'I')) == 32);
cout << "Passed TEST 4: convertTemperature(0, 'I')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 4 convertTemperature(0, 'I') #\n";
}
try {
btassert<bool>(static_cast<int>(c.convertTemperature(100, 'I')) == 212);
cout << "Passed TEST 5: convertTemperature(100, 'I')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 5 convertTemperature(100, 'I') #\n";
}
try {
btassert<bool>(c.convertDistance(300, 'M') > 91.43f && c.convertDistance(300, 'M') < 91.45f);
cout << "Passed TEST 6: convertDistance(300, 'M')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 6 convertDistance(300, 'M') #\n";
}
try {
btassert<bool>(c.convertDistance(5280, 'M') > 1609.3f && c.convertDistance(5280, 'M') < 1609.4f);
cout << "Passed TEST 7: convertDistance(5280, 'M')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 7 convertDistance(5280, 'M') #\n";
}
try {
btassert<bool>(c.convertDistance(1, 'M') > .30f && c.convertDistance(1, 'M') < .31f);
cout << "Passed TEST 8: convertDistance(1, 'M')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 8 convertDistance(1, 'M') #\n";
}
try {
btassert<bool>(c.convertDistance(1, 'I') > 3.28f && c.convertDistance(1, 'I') < 3.29f);
cout << "Passed TEST 9: convertDistance(1, 'I')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 9 convertDistance(1, 'I') #\n";
}
try {
btassert<bool>(c.convertDistance(.5f, 'I') > 1.6f && c.convertDistance(.5f, 'I') < 1.7f);
cout << "Passed TEST 10: convertDistance(.5f, 'I')\n";
++utPassed;
} catch (bool b) {
cout << "# FAILED TEST 10 convertDistance(.5f, 'I') #\n";
}
cout << "\nUNIT TEST COMPLETE\n\n";
cout << "PASSED " << utPassed << " OF " << utCount << " UNIT TEST";
if (utCount > 1) {
cout << "S";
}
cout << "\n\n";
}