Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/tests/gtest/TestID.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsID.h"
7
8
#include "gtest/gtest.h"
9
10
static const char* const ids[] = {
11
  "5C347B10-D55C-11D1-89B7-006008911B81",
12
  "{5C347B10-D55C-11D1-89B7-006008911B81}",
13
  "5c347b10-d55c-11d1-89b7-006008911b81",
14
  "{5c347b10-d55c-11d1-89b7-006008911b81}",
15
16
  "FC347B10-D55C-F1D1-F9B7-006008911B81",
17
  "{FC347B10-D55C-F1D1-F9B7-006008911B81}",
18
  "fc347b10-d55c-f1d1-f9b7-006008911b81",
19
  "{fc347b10-d55c-f1d1-f9b7-006008911b81}",
20
};
21
0
#define NUM_IDS ((int) (sizeof(ids) / sizeof(ids[0])))
22
23
TEST(nsID, StringConversion)
24
0
{
25
0
  nsID id;
26
0
  for (int i = 0; i < NUM_IDS; i++) {
27
0
    const char* idstr = ids[i];
28
0
    ASSERT_TRUE(id.Parse(idstr));
29
0
30
0
    char* cp = id.ToString();
31
0
    ASSERT_NE(cp, nullptr);
32
0
    ASSERT_STREQ(cp, ids[4*(i/4) + 3]);
33
0
34
0
    free(cp);
35
0
  }
36
0
}