test/baudrate.cpp: Use orthogonal names for the test-targets
[libftdi] / test / baudrate.cpp
index 0d2e0b8..2ffcb8a 100644 (file)
@@ -87,10 +87,24 @@ static void test_baudrates(ftdi_context *ftdi, const map<int, calc_result> &baud
 
         const calc_result *res = &baudrate.second;
 
-        unsigned short divisor = calc_value & 0x3ff;
-        unsigned short fractional_bits = (calc_index & 0x100) ? 4 : (calc_value >> 12);
-        unsigned short clock = (calc_index & 0x100) ? 120 : 48;
-
+        unsigned short divisor = calc_value & 0x3fff;
+        unsigned short fractional_bits = (calc_value >> 14);
+        unsigned short clock = (calc_index & 0x200) ? 120 : 48;
+
+        switch (ftdi->type)
+        {
+        case TYPE_232H:
+        case TYPE_2232H:
+        case TYPE_4232H:
+            fractional_bits |= (calc_index & 0x100) ? 4 : 0;
+            break;
+        case TYPE_R:
+        case TYPE_2232C:
+        case TYPE_BM:
+            fractional_bits |= (calc_index & 0x001) ? 4 : 0;
+            break;
+        default:;
+        }
         // Aid debugging since this test is a generic function
         BOOST_CHECK_MESSAGE(res->actual_baudrate == calc_baudrate && res->divisor == divisor && res->fractional_bits == fractional_bits
                             && res->clock == clock,
@@ -125,7 +139,7 @@ BOOST_AUTO_TEST_CASE(TypeAMFixedBaudrates)
     test_baudrates(ftdi, baudrates);
 }
 
-BOOST_AUTO_TEST_CASE(Type_BM_232C_R_FixedBaudrates)
+BOOST_AUTO_TEST_CASE(TypeBMFixedBaudrates)
 {
     // Unify testing of chips behaving the same
     std::vector<enum ftdi_chip_type> test_types;
@@ -155,7 +169,7 @@ BOOST_AUTO_TEST_CASE(Type_BM_232C_R_FixedBaudrates)
     }
 }
 
-BOOST_AUTO_TEST_CASE(Type_x232H_FixedBaudrates)
+BOOST_AUTO_TEST_CASE(TypeHFixedBaudrates)
 {
     // Unify testing of chips behaving the same
     std::vector<enum ftdi_chip_type> test_types;