174f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes/* 274f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * Copyright (C) 2013 The Android Open Source Project 374f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * 474f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 574f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * you may not use this file except in compliance with the License. 674f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * You may obtain a copy of the License at 774f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * 874f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 974f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * 1074f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * Unless required by applicable law or agreed to in writing, software 1174f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 1274f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1374f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * See the License for the specific language governing permissions and 1474f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes * limitations under the License. 1574f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes */ 1674f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes 1774f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes#include <gtest/gtest.h> 1874f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes 1974f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes#include <stdio.h> 2074f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes#include <inttypes.h> 2174f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes 2274f0833df6d04d51eb4e554845862ed7279f78b0Elliott HughesTEST(inttypes, misc) { 2374f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes char buf[512]; 2474f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes 2574f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes intptr_t i = 0; 2674f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes uintptr_t u = 0; 2774f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes 2874f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes snprintf(buf, sizeof(buf), "%08" PRIdPTR, i); 2974f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes snprintf(buf, sizeof(buf), "%08" PRIiPTR, i); 3074f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes snprintf(buf, sizeof(buf), "%08" PRIoPTR, i); 3174f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes snprintf(buf, sizeof(buf), "%08" PRIuPTR, u); 3274f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes snprintf(buf, sizeof(buf), "%08" PRIxPTR, u); 3374f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes snprintf(buf, sizeof(buf), "%08" PRIXPTR, u); 3474f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes 3574f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes sscanf(buf, "%08" SCNdPTR, &i); 3674f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes sscanf(buf, "%08" SCNiPTR, &i); 3774f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes sscanf(buf, "%08" SCNoPTR, &u); 3874f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes sscanf(buf, "%08" SCNuPTR, &u); 3974f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes sscanf(buf, "%08" SCNxPTR, &u); 4074f0833df6d04d51eb4e554845862ed7279f78b0Elliott Hughes} 4101ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes 4201ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott HughesTEST(inttypes, wcstoimax) { 4301ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes ASSERT_EQ(123, wcstoimax(L"123", NULL, 10)); 4401ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes} 4501ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes 4601ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott HughesTEST(inttypes, wcstoumax) { 4701ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes ASSERT_EQ(123U, wcstoumax(L"123", NULL, 10)); 4801ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes} 49