1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/tests/TestID.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +#include <stdio.h> 1.9 +#include "plstr.h" 1.10 +#include "nsID.h" 1.11 + 1.12 +static const char* const ids[] = { 1.13 + "5C347B10-D55C-11D1-89B7-006008911B81", 1.14 + "{5C347B10-D55C-11D1-89B7-006008911B81}", 1.15 + "5c347b10-d55c-11d1-89b7-006008911b81", 1.16 + "{5c347b10-d55c-11d1-89b7-006008911b81}", 1.17 + 1.18 + "FC347B10-D55C-F1D1-F9B7-006008911B81", 1.19 + "{FC347B10-D55C-F1D1-F9B7-006008911B81}", 1.20 + "fc347b10-d55c-f1d1-f9b7-006008911b81", 1.21 + "{fc347b10-d55c-f1d1-f9b7-006008911b81}", 1.22 +}; 1.23 +#define NUM_IDS ((int) (sizeof(ids) / sizeof(ids[0]))) 1.24 + 1.25 +int main(int argc, char** argv) 1.26 +{ 1.27 + nsID id; 1.28 + for (int i = 0; i < NUM_IDS; i++) { 1.29 + const char* idstr = ids[i]; 1.30 + if (!id.Parse(idstr)) { 1.31 + fprintf(stderr, "TestID: Parse failed on test #%d\n", i); 1.32 + return -1; 1.33 + } 1.34 + char* cp = id.ToString(); 1.35 + if (nullptr == cp) { 1.36 + fprintf(stderr, "TestID: ToString failed on test #%d\n", i); 1.37 + return -1; 1.38 + } 1.39 + if (0 != PL_strcmp(cp, ids[4*(i/4) + 3])) { 1.40 + fprintf(stderr, "TestID: compare of ToString failed on test #%d\n", i); 1.41 + return -1; 1.42 + } 1.43 + } 1.44 + 1.45 + return 0; 1.46 +}