// Path: src/main/java/uk/org/okapibarcode/backend/UspsOneCode.java
// protected static String formatHumanReadableText(String content) {
//     StringBuilder hrt = new StringBuilder(50);
//     boolean mid9 = false; // 9-digit mailer ID instead of 6-digit mailer ID
//     boolean tracing = true; // STID indicates Origin IMb Tracing Services (050, 052)
//     boolean pimb = true; // barcode identifier (BI) is 94, indicating pIMb
//     boolean mpe5 = false; // if MPE = 5, it's a CFS/RFS variant of pIMb
//     int i = 0;
//     for (char c : content.toCharArray()) {
//         if (c < '0' || c > '9') {
//             continue;
//         }
//         if (i == 5 && c == '9') {
//             mid9 = true;
//         }
//         if ((i == 2 && c != '0') || (i == 3 && c != '5') || (i == 4 && c != '0' && c != '2')) {
//             tracing = false;
//         }
//         if ((i == 0 && c != '9') || (i == 1 && c != '4')) {
//             pimb = false;
//         }
//         if (i == 5 && c == '5') {
//             mpe5 = true;
//         }
//         if ((i == 2) // BI -> STID
//          || (i == 5) // STID -> ...
//          || (i == 6 && pimb)
//          || (i == 10 && pimb)
//          || (i == 13 && pimb && !mpe5)
//          || (i == 15 && pimb && !mpe5)
//          || (i == 11 && !mid9 && !tracing && !pimb)
//          || (i == 14 && mid9 && !tracing && !pimb)
//          || (i == 20) // ... -> zip-5
//          || (i == 25) // zip-5 -> zip-4
//          || (i == 29)) { // zip-4 -> zip-2
//             hrt.append(' ');
//         }
//         hrt.append(c);
//         i++;
//     }
//     return hrt.toString().trim();
// }


import static org.junit.Assert.assertEquals;
import static uk.org.okapibarcode.backend.UspsOneCode.formatHumanReadableText;
import org.junit.Test;
/*
 * Copyright 2019 Daniel Gredler
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.org.okapibarcode.backend;



/**
 * {@link UspsOneCode} tests that can't be run via the {@link SymbolTest}.
 */
public class UspsOneCodeTest {

    @Test
    public void testFormatHumanReadableText() {

        // 6-digit mailer IDs: 000000-899999
        // 9-digit mailer IDs: 900000000-999999999

        // 11.3.1.1, Table 26 (6-digit mailer ID)
        // 11.3.2.3, Table 36 (6-digit mailer ID, BI = 93)
// Path: src/main/java/uk/org/okapibarcode/backend/UspsOneCode.java
// protected static String formatHumanReadableText(String content) {
//     StringBuilder hrt = new StringBuilder(50);
//     boolean mid9 = false; // 9-digit mailer ID instead of 6-digit mailer ID
//     boolean tracing = true; // STID indicates Origin IMb Tracing Services (050, 052)
//     boolean pimb = true; // barcode identifier (BI) is 94, indicating pIMb
//     boolean mpe5 = false; // if MPE = 5, it's a CFS/RFS variant of pIMb
//     int i = 0;
//     for (char c : content.toCharArray()) {
//         if (c < '0' || c > '9') {
//             continue;
//         }
//         if (i == 5 && c == '9') {
//             mid9 = true;
//         }
//         if ((i == 2 && c != '0') || (i == 3 && c != '5') || (i == 4 && c != '0' && c != '2')) {
//             tracing = false;
//         }
//         if ((i == 0 && c != '9') || (i == 1 && c != '4')) {
//             pimb = false;
//         }
//         if (i == 5 && c == '5') {
//             mpe5 = true;
//         }
//         if ((i == 2) // BI -> STID
//          || (i == 5) // STID -> ...
//          || (i == 6 && pimb)
//          || (i == 10 && pimb)
//          || (i == 13 && pimb && !mpe5)
//          || (i == 15 && pimb && !mpe5)
//          || (i == 11 && !mid9 && !tracing && !pimb)
//          || (i == 14 && mid9 && !tracing && !pimb)
//          || (i == 20) // ... -> zip-5
//          || (i == 25) // zip-5 -> zip-4
//          || (i == 29)) { // zip-4 -> zip-2
//             hrt.append(' ');
//         }
//         hrt.append(c);
//         i++;
//     }
//     return hrt.toString().trim();
// }


// Path: src/test/java/uk/org/okapibarcode/backend/UspsOneCodeTest.java
import static org.junit.Assert.assertEquals;
import static uk.org.okapibarcode.backend.UspsOneCode.formatHumanReadableText;
import org.junit.Test;

/*
 * Copyright 2019 Daniel Gredler
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.org.okapibarcode.backend;



/**
 * {@link UspsOneCode} tests that can't be run via the {@link SymbolTest}.
 */
public class UspsOneCodeTest {

    @Test
    public void testFormatHumanReadableText() {

        // 6-digit mailer IDs: 000000-899999
        // 9-digit mailer IDs: 900000000-999999999

        // 11.3.1.1, Table 26 (6-digit mailer ID)
        // 11.3.2.3, Table 36 (6-digit mailer ID, BI = 93)
        assertEquals("12 123 123456 123456789",               formatHumanReadableText("12.123.123456.123456789"));             // zip code: none