/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * 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.
 */
/*
 * Note that similar (or almost same) tests exist in Java side (See
 * DatabaseGeneralTest.java in AndroidTests). The differences are:
 * - this test is quite easy to do (You can do it in your Unix PC)
 * - this test is not automatically executed by build servers
 *
 * You should also execute the test before submitting this.
 */

#include "PhoneNumberUtils.h"

#include <stdio.h>
#include <string.h>

using namespace android;

#define EXPECT(function, input1, input2, expected, total, error)        \
    ({                                                                  \
        const char *i1_cache = input1;                                  \
        const char *i2_cache = input2;                                  \
        (total)++;                                                      \
        if ((expected) != (function)((i1_cache), (i2_cache))) {         \
            if (expected) {                                             \
                printf("%s != %s while we expect %s == %s\n",           \
                       (i1_cache), (i2_cache), (i1_cache), (i2_cache)); \
            } else {                                                    \
                printf("%s == %s while we expect %s != %s\n",           \
                       (i1_cache), (i2_cache), (i1_cache), (i2_cache)); \
            }                                                           \
            (error)++;                                                  \
        }                                                               \
    })

#define EXPECT_EQ(input1, input2)                                       \
    EXPECT(phone_number_compare, (input1), (input2), true,              \
           (total), (error))


#define EXPECT_NE(input1, input2)                                       \
    EXPECT(phone_number_compare, (input1), (input2), false,             \
           (total), (error))

int main() {
    int total = 0;
    int error = 0;

    EXPECT_EQ(NULL, NULL);
    EXPECT_EQ("", NULL);
    EXPECT_EQ(NULL, "");
    EXPECT_EQ("", "");

    EXPECT_EQ("999", "999");
    EXPECT_EQ("119", "119");

    EXPECT_NE("123456789", "923456789");
    EXPECT_NE("123456789", "123456781");
    EXPECT_NE("123456789", "1234567890");
    EXPECT_NE("123456789", "0123456789");

    // Google, Inc.
    EXPECT_EQ("650-253-0000", "6502530000");
    EXPECT_EQ("650-253-0000", "650 253 0000");
    EXPECT_EQ("650 253 0000", "6502530000");

    // trunk (NDD) prefix must be properly handled in US
    EXPECT_EQ("650-253-0000", "1-650-253-0000");
    EXPECT_EQ("650-253-0000", "   1-650-253-0000");
    EXPECT_NE("650-253-0000", "11-650-253-0000");
    EXPECT_NE("650-253-0000", "0-650-253-0000");

    EXPECT_EQ("+1 650-253-0000", "6502530000");
    EXPECT_EQ("001 650-253-0000", "6502530000");
    EXPECT_EQ("0111 650-253-0000", "6502530000");

    // Country code is different.
    EXPECT_NE("+19012345678", "+819012345678");

    // Russian trunk digit
    EXPECT_EQ("+79161234567", "89161234567");

    // French trunk digit
    EXPECT_EQ("+33123456789", "0123456789");

    // Trunk digit for city codes in the Netherlands
    EXPECT_EQ("+31771234567", "0771234567");

    // Japanese dial
    EXPECT_EQ("090-1234-5678", "+819012345678");
    EXPECT_EQ("090(1234)5678", "+819012345678");
    EXPECT_EQ("090-1234-5678", "+81-90-1234-5678");

    // Trunk prefix must not be ignored in Japan
    EXPECT_NE("090-1234-5678", "90-1234-5678");

    EXPECT_NE("090-1234-5678", "080-1234-5678");
    EXPECT_NE("090-1234-5678", "190-1234-5678");
    EXPECT_NE("090-1234-5678", "890-1234-5678");
    EXPECT_NE("+81-90-1234-5678", "+81-090-1234-5678");

    EXPECT_EQ("+593(800)123-1234", "8001231234");

    // Two continuous 0 at the beginieng of the phone string should not be
    // treated as trunk prefix.
    EXPECT_NE("008001231234", "8001231234");

    // Test broken caller ID seen on call from Thailand to the US
    EXPECT_EQ("+66811234567", "166811234567");

    // Confirm that the bug found before does not re-appear.
    EXPECT_NE("080-1234-5678", "+819012345678");
    EXPECT_EQ("650-000-3456", "16500003456");
    EXPECT_EQ("16610001234", "6610001234");

    // We also need to compare two alpha addresses to make sure two different strings
    // aren't treated as the same addresses. This is relevant to SMS as SMS sender may
    // contain all alpha chars.
    EXPECT_NE("abcd", "bcde");

    // in the U.S. people often use alpha in the phone number to easily remember it
    // (e.g. 800-flowers would be dialed as 800-356-9377). Since we accept this form of
    // phone number in Contacts and others, we should make sure the comparison method
    // handle them.
    EXPECT_EQ("1-800-flowers", "800-flowers");

    // TODO: we currently do not support this comparison. It maybe nice to support this
    // TODO: in the future.
    // EXPECT_EQ("1-800-flowers", "1-800-356-9377")

    EXPECT_NE("1-800-flowers", "1-800-abcdefg");

    // Currently we cannot get this test through (Japanese trunk prefix is 0,
    // but there is no sensible way to know it now (as of 2009-6-12)...
    // EXPECT_NE("290-1234-5678", "+819012345678");

    printf("total: %d, error: %d\n\n", total, error);
    if (error == 0) {
        printf("Success!\n");
    } else {
        printf("Failure... :(\n");
    }
}
