Bug 1002600: fix test_mms_pdu_helper.js intermittent timeouts. r=gene, a=test-only
authorVicamo Yang <vyang@mozilla.com>
Thu, 03 Jul 2014 18:46:42 +0800
changeset 207611 d5c726affb058284ba2c72c35fed6c09775b49d1
parent 207610 698add2d869a9614ec0dfa4e680fa90919b4daea
child 207612 0e542146dd60e5489f82f771c7edb0a9c4d27c38
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgene, test-only
bugs1002600
milestone32.0a2
Bug 1002600: fix test_mms_pdu_helper.js intermittent timeouts. r=gene, a=test-only
dom/mobilemessage/tests/xpcshell/test_mms_pdu_helper.js
--- a/dom/mobilemessage/tests/xpcshell/test_mms_pdu_helper.js
+++ b/dom/mobilemessage/tests/xpcshell/test_mms_pdu_helper.js
@@ -11,25 +11,25 @@ function run_test() {
 
 //
 // Test target: BooleanValue
 //
 
 //// BooleanValue.decode ////
 
 add_test(function test_BooleanValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if (i == 128) {
-      wsp_decode_test(MMS.BooleanValue, [128], true);
-    } else if (i == 129) {
-      wsp_decode_test(MMS.BooleanValue, [129], false);
-    } else {
-      wsp_decode_test(MMS.BooleanValue, [i], null, "CodeError");
-    }
-  }
+  // Valid codes are 128 and 129. Check boundary conditions 0, 1, 127, 130 and
+  // 255 as well.
+  wsp_decode_test(MMS.BooleanValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.BooleanValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.BooleanValue, [127], null, "CodeError");
+  wsp_decode_test(MMS.BooleanValue, [128], true);
+  wsp_decode_test(MMS.BooleanValue, [129], false);
+  wsp_decode_test(MMS.BooleanValue, [130], null, "CodeError");
+  wsp_decode_test(MMS.BooleanValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// BooleanValue.encode ////
 
 add_test(function test_BooleanValue_encode() {
   wsp_encode_test(MMS.BooleanValue, true, [128]);
@@ -456,69 +456,79 @@ add_test(function test_MmsHeader_encode(
 
 //
 // Test target: CancelStatusValue
 //
 
 //// CancelStatusValue.decode ////
 
 add_test(function test_CancelStatusValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 129)) {
-      wsp_decode_test(MMS.CancelStatusValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.CancelStatusValue, [i], null, "CodeError");
-    }
-  }
+  // Valid codes are 128 and 129. Check boundary conditions 0, 1, 127, 130 and
+  // 255 as well.
+  wsp_decode_test(MMS.CancelStatusValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.CancelStatusValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.CancelStatusValue, [127], null, "CodeError");
+  wsp_decode_test(MMS.CancelStatusValue, [128], 128);
+  wsp_decode_test(MMS.CancelStatusValue, [129], 129);
+  wsp_decode_test(MMS.CancelStatusValue, [130], null, "CodeError");
+  wsp_decode_test(MMS.CancelStatusValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// CancelStatusValue.encode ////
 
 add_test(function test_CancelStatusValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 129)) {
-      wsp_encode_test(MMS.CancelStatusValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.CancelStatusValue, i, null, "CodeError");
-    }
-  }
+  // Valid codes are 128 and 129. Check boundary conditions 0, 1, 127, 130 and
+  // 255 as well.
+  wsp_encode_test(MMS.CancelStatusValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.CancelStatusValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.CancelStatusValue, 127, null, "CodeError");
+  wsp_encode_test(MMS.CancelStatusValue, 128, [128]);
+  wsp_encode_test(MMS.CancelStatusValue, 129, [129]);
+  wsp_encode_test(MMS.CancelStatusValue, 130, null, "CodeError");
+  wsp_encode_test(MMS.CancelStatusValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: ContentClassValue
 //
 
 //// ContentClassValue.decode ////
 
 add_test(function test_ContentClassValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 135)) {
-      wsp_decode_test(MMS.ContentClassValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.ContentClassValue, [i], null, "CodeError");
-    }
+  // Valid codes are 128 - 135. Check boundary conditions 0, 1, 127, 136 and
+  // 255 as well.
+  wsp_decode_test(MMS.ContentClassValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.ContentClassValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.ContentClassValue, [127], null, "CodeError");
+  for (let i = 128; i <= 135; i++) {
+    wsp_decode_test(MMS.ContentClassValue, [i], i);
   }
+  wsp_decode_test(MMS.ContentClassValue, [136], null, "CodeError");
+  wsp_decode_test(MMS.ContentClassValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// ContentClassValue.encode ////
 
 add_test(function test_ContentClassValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 135)) {
-      wsp_encode_test(MMS.ContentClassValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.ContentClassValue, i, null, "CodeError");
-    }
+  // Valid codes are 128 - 135. Check boundary conditions 0, 1, 127, 136 and
+  // 255 as well.
+  wsp_encode_test(MMS.ContentClassValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.ContentClassValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.ContentClassValue, 127, null, "CodeError");
+  for (let i = 128; i <= 135; i++) {
+    wsp_encode_test(MMS.ContentClassValue, i, [i]);
   }
+  wsp_encode_test(MMS.ContentClassValue, 136, null, "CodeError");
+  wsp_encode_test(MMS.ContentClassValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: ContentLocationValue
 //
 
@@ -804,32 +814,36 @@ add_test(function test_FromValue_encode(
 
 //
 // Test target: MessageClassValue
 //
 
 //// MessageClassValue.decodeClassIdentifier ////
 
 add_test(function test_MessageClassValue_decodeClassIdentifier() {
-  let (IDs = ["personal", "advertisement", "informational", "auto"]) {
-    for (let i = 0; i < 256; i++) {
-      if ((i >= 128) && (i <= 131)) {
-        wsp_decode_test_ex(function(data) {
-            return MMS.MessageClassValue.decodeClassIdentifier(data);
-          }, [i], IDs[i - 128]
-        );
-      } else {
-        wsp_decode_test_ex(function(data) {
-            return MMS.MessageClassValue.decodeClassIdentifier(data);
-          }, [i], null, "CodeError"
-        );
-      }
-    }
+  const IDs = ["personal", "advertisement", "informational", "auto"];
+
+  function test(i, error) {
+    let id = IDs[i - 128];
+    wsp_decode_test_ex(function(data) {
+        return MMS.MessageClassValue.decodeClassIdentifier(data);
+      }, [i], (error ? null : id), error);
   }
 
+  // Valid codes are 128 - 131. Check boundary conditions 0, 1, 127, 132 and
+  // 255 as well.
+  test(0, "CodeError");
+  test(1, "CodeError");
+  test(127, "CodeError");
+  for (let i = 128; i <= 131; i++) {
+    test(i, null);
+  }
+  test(132, "CodeError");
+  test(255, "CodeError");
+
   run_next_test();
 });
 
 //// MessageClassValue.decode ////
 
 add_test(function test_MessageClassValue_decode() {
   wsp_decode_test(MMS.MessageClassValue, [65, 0], "A");
   wsp_decode_test(MMS.MessageClassValue, [128], "personal");
@@ -851,215 +865,250 @@ add_test(function test_MessageClassValue
 
 //
 // Test target: MessageTypeValue
 //
 
 //// MessageTypeValue.decode ////
 
 add_test(function test_MessageTypeValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 151)) {
-      wsp_decode_test(MMS.MessageTypeValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.MessageTypeValue, [i], null, "CodeError");
-    }
+  // Valid codes are 128 - 151. Check boundary conditions 0, 1, 127, 152 and
+  // 255 as well.
+  wsp_decode_test(MMS.MessageTypeValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.MessageTypeValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.MessageTypeValue, [127], null, "CodeError");
+  for (let i = 128; i <= 151; i++) {
+    wsp_decode_test(MMS.MessageTypeValue, [i], i);
   }
+  wsp_decode_test(MMS.MessageTypeValue, [152], null, "CodeError");
+  wsp_decode_test(MMS.MessageTypeValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// MessageTypeValue.encode ////
 
 add_test(function test_MessageTypeValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 151)) {
-      wsp_encode_test(MMS.MessageTypeValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.MessageTypeValue, i, null, "CodeError");
-    }
+  // Valid codes are 128 - 151. Check boundary conditions 0, 1, 127, 152 and
+  // 255 as well.
+  wsp_encode_test(MMS.MessageTypeValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.MessageTypeValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.MessageTypeValue, 127, null, "CodeError");
+  for (let i = 128; i <= 151; i++) {
+    wsp_encode_test(MMS.MessageTypeValue, i, [i]);
   }
+  wsp_encode_test(MMS.MessageTypeValue, 152, null, "CodeError");
+  wsp_encode_test(MMS.MessageTypeValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: MmFlagsValue
 //
 
 //// MmFlagsValue.decode ////
 
 add_test(function test_MmFlagsValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 130)) {
-      wsp_decode_test(MMS.MmFlagsValue, [3, i, 65, 0], {type: i, text: "A"});
-    } else {
-      wsp_decode_test(MMS.MmFlagsValue, [3, i, 65, 0], null, "CodeError");
-    }
+  // Valid codes are 128 - 130. Check boundary conditions 0, 1, 127, 131 and
+  // 255 as well.
+  wsp_decode_test(MMS.MmFlagsValue, [3, 0, 65, 0], null, "CodeError");
+  wsp_decode_test(MMS.MmFlagsValue, [3, 1, 65, 0], null, "CodeError");
+  wsp_decode_test(MMS.MmFlagsValue, [3, 127, 65, 0], null, "CodeError");
+  for (let i = 128; i <= 130; i++) {
+    wsp_decode_test(MMS.MmFlagsValue, [3, i, 65, 0], {type: i, text: "A"});
   }
+  wsp_decode_test(MMS.MmFlagsValue, [3, 131, 65, 0], null, "CodeError");
+  wsp_decode_test(MMS.MmFlagsValue, [3, 255, 65, 0], null, "CodeError");
 
   run_next_test();
 });
 
 //// MmFlagsValue.encode ////
 
 add_test(function test_MmFlagsValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 130)) {
-      wsp_encode_test(MMS.MmFlagsValue, {type: i, text: "A"}, [3, i, 65, 0]);
-    } else {
-      wsp_encode_test(MMS.MmFlagsValue, {type: i, text: "A"}, null, "CodeError");
-    }
+  // Valid codes are 128 - 130. Check boundary conditions 0, 1, 127, 131 and
+  // 255 as well.
+  wsp_encode_test(MMS.MmFlagsValue, {type: 0, text: "A"}, null, "CodeError");
+  wsp_encode_test(MMS.MmFlagsValue, {type: 1, text: "A"}, null, "CodeError");
+  wsp_encode_test(MMS.MmFlagsValue, {type: 127, text: "A"}, null, "CodeError");
+  for (let i = 128; i <= 130; i++) {
+    wsp_encode_test(MMS.MmFlagsValue, {type: i, text: "A"}, [3, i, 65, 0]);
   }
+  wsp_encode_test(MMS.MmFlagsValue, {type: 131, text: "A"}, null, "CodeError");
+  wsp_encode_test(MMS.MmFlagsValue, {type: 255, text: "A"}, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: MmStateValue
 //
 
 //// MmStateValue.decode ////
 
 add_test(function test_MmStateValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 132)) {
-      wsp_decode_test(MMS.MmStateValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.MmStateValue, [i], null, "CodeError");
-    }
+  // Valid codes are 128 - 132. Check boundary conditions 0, 1, 127, 133 and
+  // 255 as well.
+  wsp_decode_test(MMS.MmStateValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.MmStateValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.MmStateValue, [127], null, "CodeError");
+  for (let i = 128; i <= 132; i++) {
+    wsp_decode_test(MMS.MmStateValue, [i], i);
   }
+  wsp_decode_test(MMS.MmStateValue, [133], null, "CodeError");
+  wsp_decode_test(MMS.MmStateValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// MmStateValue.encode ////
 
 add_test(function test_MmStateValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 132)) {
-      wsp_encode_test(MMS.MmStateValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.MmStateValue, i, null, "CodeError");
-    }
+  // Valid codes are 128 - 132. Check boundary conditions 0, 1, 127, 133 and
+  // 255 as well.
+  wsp_encode_test(MMS.MmStateValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.MmStateValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.MmStateValue, 127, null, "CodeError");
+  for (let i = 128; i <= 132; i++) {
+    wsp_encode_test(MMS.MmStateValue, i, [i]);
   }
+  wsp_encode_test(MMS.MmStateValue, 133, null, "CodeError");
+  wsp_encode_test(MMS.MmStateValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: PriorityValue
 //
 
 //// PriorityValue.decode ////
 
 add_test(function test_PriorityValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 130)) {
-      wsp_decode_test(MMS.PriorityValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.PriorityValue, [i], null, "CodeError");
-    }
+  // Valid codes are 128 - 130. Check boundary conditions 0, 1, 127, 131 and
+  // 255 as well.
+  wsp_decode_test(MMS.PriorityValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.PriorityValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.PriorityValue, [127], null, "CodeError");
+  for (let i = 128; i <= 130; i++) {
+    wsp_decode_test(MMS.PriorityValue, [i], i);
   }
+  wsp_decode_test(MMS.PriorityValue, [131], null, "CodeError");
+  wsp_decode_test(MMS.PriorityValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// PriorityValue.encode ////
 
 add_test(function test_PriorityValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 130)) {
-      wsp_encode_test(MMS.PriorityValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.PriorityValue, i, null, "CodeError");
-    }
+  // Valid codes are 128 - 130. Check boundary conditions 0, 1, 127, 131 and
+  // 255 as well.
+  wsp_encode_test(MMS.PriorityValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.PriorityValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.PriorityValue, 127, null, "CodeError");
+  for (let i = 128; i <= 130; i++) {
+    wsp_encode_test(MMS.PriorityValue, i, [i]);
   }
+  wsp_encode_test(MMS.PriorityValue, 131, null, "CodeError");
+  wsp_encode_test(MMS.PriorityValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: ReadStatusValue
 //
 
 //// ReadStatusValue.decode ////
 
 add_test(function test_ReadStatusValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 129)) {
-      wsp_decode_test(MMS.ReadStatusValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.ReadStatusValue, [i], null, "CodeError");
-    }
-  }
+  // Valid codes are 128, 129. Check boundary conditions 0, 1, 127, 130 and
+  // 255 as well.
+  wsp_decode_test(MMS.ReadStatusValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.ReadStatusValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.ReadStatusValue, [127], null, "CodeError");
+  wsp_decode_test(MMS.ReadStatusValue, [128], 128);
+  wsp_decode_test(MMS.ReadStatusValue, [129], 129);
+  wsp_decode_test(MMS.ReadStatusValue, [130], null, "CodeError");
+  wsp_decode_test(MMS.ReadStatusValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// ReadStatusValue.encode ////
 
 add_test(function test_ReadStatusValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 129)) {
-      wsp_encode_test(MMS.ReadStatusValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.ReadStatusValue, i, null, "CodeError");
-    }
-  }
+  // Valid codes are 128, 129. Check boundary conditions 0, 1, 127, 130 and
+  // 255 as well.
+  wsp_encode_test(MMS.ReadStatusValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.ReadStatusValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.ReadStatusValue, 127, null, "CodeError");
+  wsp_encode_test(MMS.ReadStatusValue, 128, [128]);
+  wsp_encode_test(MMS.ReadStatusValue, 129, [129]);
+  wsp_encode_test(MMS.ReadStatusValue, 130, null, "CodeError");
+  wsp_encode_test(MMS.ReadStatusValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: RecommendedRetrievalModeValue
 //
 
 //// RecommendedRetrievalModeValue.decode ////
 
 add_test(function test_RecommendedRetrievalModeValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if (i == 128) {
-      wsp_decode_test(MMS.RecommendedRetrievalModeValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.RecommendedRetrievalModeValue, [i], null, "CodeError");
-    }
-  }
+  // Valid codes is 128. Check boundary conditions 0, 1, 127, 130 and 255 as
+  // well.
+  wsp_decode_test(MMS.RecommendedRetrievalModeValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.RecommendedRetrievalModeValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.RecommendedRetrievalModeValue, [127], null, "CodeError");
+  wsp_decode_test(MMS.RecommendedRetrievalModeValue, [128], 128);
+  wsp_decode_test(MMS.RecommendedRetrievalModeValue, [129], null, "CodeError");
+  wsp_decode_test(MMS.RecommendedRetrievalModeValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: ReplyChargingValue
 //
 
 //// ReplyChargingValue.decode ////
 
 add_test(function test_ReplyChargingValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 131)) {
-      wsp_decode_test(MMS.ReplyChargingValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.ReplyChargingValue, [i], null, "CodeError");
-    }
+  // Valid codes are 128 - 131. Check boundary conditions 0, 1, 127, 132 and
+  // 255 as well.
+  wsp_decode_test(MMS.ReplyChargingValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.ReplyChargingValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.ReplyChargingValue, [127], null, "CodeError");
+  for (let i = 128; i <= 131; i++) {
+    wsp_decode_test(MMS.ReplyChargingValue, [i], i);
   }
+  wsp_decode_test(MMS.ReplyChargingValue, [132], null, "CodeError");
+  wsp_decode_test(MMS.ReplyChargingValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// ReplyChargingValue.encode ////
 
 add_test(function test_ReplyChargingValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 131)) {
-      wsp_encode_test(MMS.ReplyChargingValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.ReplyChargingValue, i, null, "CodeError");
-    }
+  // Valid codes are 128 - 131. Check boundary conditions 0, 1, 127, 132 and
+  // 255 as well.
+  wsp_encode_test(MMS.ReplyChargingValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.ReplyChargingValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.ReplyChargingValue, 127, null, "CodeError");
+  for (let i = 128; i <= 131; i++) {
+    wsp_encode_test(MMS.ReplyChargingValue, i, [i]);
   }
+  wsp_encode_test(MMS.ReplyChargingValue, 132, null, "CodeError");
+  wsp_encode_test(MMS.ReplyChargingValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: ResponseText
 //
 
@@ -1099,89 +1148,108 @@ add_test(function test_ResponseText_deco
 
 //
 // Test target: RetrieveStatusValue
 //
 
 //// RetrieveStatusValue.decode ////
 
 add_test(function test_RetrieveStatusValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i == MMS_PDU_ERROR_OK)
-        || (i >= MMS_PDU_ERROR_TRANSIENT_FAILURE)) {
-      wsp_decode_test(MMS.RetrieveStatusValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.RetrieveStatusValue, [i],
-                      MMS_PDU_ERROR_PERMANENT_FAILURE);
-    }
+  // Valid codes are 128, 192 - 255. Check boundary conditions 0, 1, 127, 129,
+  // and 191 as well.
+  wsp_decode_test(MMS.RetrieveStatusValue, [0],
+                  MMS_PDU_ERROR_PERMANENT_FAILURE);
+  wsp_decode_test(MMS.RetrieveStatusValue, [1],
+                  MMS_PDU_ERROR_PERMANENT_FAILURE);
+  wsp_decode_test(MMS.RetrieveStatusValue, [127],
+                  MMS_PDU_ERROR_PERMANENT_FAILURE);
+
+  wsp_decode_test(MMS.RetrieveStatusValue, [128], MMS_PDU_ERROR_OK);
+
+  wsp_decode_test(MMS.RetrieveStatusValue, [129],
+                  MMS_PDU_ERROR_PERMANENT_FAILURE);
+  wsp_decode_test(MMS.RetrieveStatusValue, [191],
+                  MMS_PDU_ERROR_PERMANENT_FAILURE);
+  for (let i = 192; i < 256; i++) {
+    wsp_decode_test(MMS.RetrieveStatusValue, [i], i);
   }
 
   run_next_test();
 });
 
 //
 // Test target: SenderVisibilityValue
 //
 
 //// SenderVisibilityValue.decode ////
 
 add_test(function test_SenderVisibilityValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 129)) {
-      wsp_decode_test(MMS.SenderVisibilityValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.SenderVisibilityValue, [i], null, "CodeError");
-    }
-  }
+  // Valid codes are 128, 129. Check boundary conditions 0, 1, 127, 130 and
+  // 255 as well.
+  wsp_decode_test(MMS.SenderVisibilityValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.SenderVisibilityValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.SenderVisibilityValue, [127], null, "CodeError");
+  wsp_decode_test(MMS.SenderVisibilityValue, [128], 128);
+  wsp_decode_test(MMS.SenderVisibilityValue, [129], 129);
+  wsp_decode_test(MMS.SenderVisibilityValue, [130], null, "CodeError");
+  wsp_decode_test(MMS.SenderVisibilityValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// SenderVisibilityValue.encode ////
 
 add_test(function test_SenderVisibilityValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 129)) {
-      wsp_encode_test(MMS.SenderVisibilityValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.SenderVisibilityValue, i, null, "CodeError");
-    }
-  }
+  // Valid codes are 128, 129. Check boundary conditions 0, 1, 127, 130 and
+  // 255 as well.
+  wsp_encode_test(MMS.SenderVisibilityValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.SenderVisibilityValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.SenderVisibilityValue, 127, null, "CodeError");
+  wsp_encode_test(MMS.SenderVisibilityValue, 128, [128]);
+  wsp_encode_test(MMS.SenderVisibilityValue, 129, [129]);
+  wsp_encode_test(MMS.SenderVisibilityValue, 130, null, "CodeError");
+  wsp_encode_test(MMS.SenderVisibilityValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: StatusValue
 //
 
 //// StatusValue.decode ////
 
 add_test(function test_StatusValue_decode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 135)) {
-      wsp_decode_test(MMS.StatusValue, [i], i);
-    } else {
-      wsp_decode_test(MMS.StatusValue, [i], null, "CodeError");
-    }
+  // Valid codes are 128 - 135. Check boundary conditions 0, 1, 127, 136 and
+  // 255 as well.
+  wsp_decode_test(MMS.StatusValue, [0], null, "CodeError");
+  wsp_decode_test(MMS.StatusValue, [1], null, "CodeError");
+  wsp_decode_test(MMS.StatusValue, [127], null, "CodeError");
+  for (let i = 128; i <= 135; i++) {
+    wsp_decode_test(MMS.StatusValue, [i], i);
   }
+  wsp_decode_test(MMS.StatusValue, [136], null, "CodeError");
+  wsp_decode_test(MMS.StatusValue, [255], null, "CodeError");
 
   run_next_test();
 });
 
 //// StatusValue.encode ////
 
 add_test(function test_StatusValue_encode() {
-  for (let i = 0; i < 256; i++) {
-    if ((i >= 128) && (i <= 135)) {
-      wsp_encode_test(MMS.StatusValue, i, [i]);
-    } else {
-      wsp_encode_test(MMS.StatusValue, i, null, "CodeError");
-    }
+  // Valid codes are 128 - 135. Check boundary conditions 0, 1, 127, 136 and
+  // 255 as well.
+  wsp_encode_test(MMS.StatusValue, 0, null, "CodeError");
+  wsp_encode_test(MMS.StatusValue, 1, null, "CodeError");
+  wsp_encode_test(MMS.StatusValue, 127, null, "CodeError");
+  for (let i = 128; i <= 135; i++) {
+    wsp_encode_test(MMS.StatusValue, i, [i]);
   }
+  wsp_encode_test(MMS.StatusValue, 136, null, "CodeError");
+  wsp_encode_test(MMS.StatusValue, 255, null, "CodeError");
 
   run_next_test();
 });
 
 //
 // Test target: PduHelper
 //