Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/intl/icu/source/common/pluralmap.cpp
Line
Count
Source (jump to first uncovered line)
1
// © 2016 and later: Unicode, Inc. and others.
2
// License & terms of use: http://www.unicode.org/copyright.html
3
/*
4
 * Copyright (C) 2015, International Business Machines Corporation and
5
 * others. All Rights Reserved.
6
 */
7
8
#include "unicode/unistr.h"
9
#include "charstr.h"
10
#include "cstring.h"
11
#include "pluralmap.h"
12
13
U_NAMESPACE_BEGIN
14
15
static const char * const gPluralForms[] = {
16
        "other", "zero", "one", "two", "few", "many"};
17
18
PluralMapBase::Category
19
0
PluralMapBase::toCategory(const char *pluralForm) {
20
0
    for (int32_t i = 0; i < UPRV_LENGTHOF(gPluralForms); ++i) {
21
0
        if (uprv_strcmp(pluralForm, gPluralForms[i]) == 0) {
22
0
            return static_cast<Category>(i);
23
0
        }
24
0
    }
25
0
    return NONE;
26
0
}
27
28
PluralMapBase::Category
29
0
PluralMapBase::toCategory(const UnicodeString &pluralForm) {
30
0
    CharString cCategory;
31
0
    UErrorCode status = U_ZERO_ERROR;
32
0
    cCategory.appendInvariantChars(pluralForm, status);    
33
0
    return U_FAILURE(status) ? NONE : toCategory(cCategory.data());
34
0
}
35
36
0
const char *PluralMapBase::getCategoryName(Category c) {
37
0
    int32_t index = c;
38
0
    return (index < 0 || index >= UPRV_LENGTHOF(gPluralForms)) ?
39
0
            NULL : gPluralForms[index];
40
0
}
41
42
43
U_NAMESPACE_END
44