/src/mozilla-central/modules/libpref/test/gtest/Basics.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "gtest/gtest.h" |
8 | | #include "mozilla/Preferences.h" |
9 | | |
10 | | using namespace mozilla; |
11 | | |
12 | | TEST(PrefsBasics, Errors) |
13 | 0 | { |
14 | 0 | Preferences::SetBool("foo.bool", true, PrefValueKind::Default); |
15 | 0 | Preferences::SetBool("foo.bool", false, PrefValueKind::User); |
16 | 0 | ASSERT_EQ(Preferences::GetBool("foo.bool", false, PrefValueKind::Default), |
17 | 0 | true); |
18 | 0 | ASSERT_EQ(Preferences::GetBool("foo.bool", true, PrefValueKind::User), false); |
19 | 0 |
|
20 | 0 | Preferences::SetInt("foo.int", -66, PrefValueKind::Default); |
21 | 0 | Preferences::SetInt("foo.int", -77, PrefValueKind::User); |
22 | 0 | ASSERT_EQ(Preferences::GetInt("foo.int", 1, PrefValueKind::Default), -66); |
23 | 0 | ASSERT_EQ(Preferences::GetInt("foo.int", 1, PrefValueKind::User), -77); |
24 | 0 |
|
25 | 0 | Preferences::SetUint("foo.uint", 88, PrefValueKind::Default); |
26 | 0 | Preferences::SetUint("foo.uint", 99, PrefValueKind::User); |
27 | 0 | ASSERT_EQ(Preferences::GetUint("foo.uint", 1, PrefValueKind::Default), 88U); |
28 | 0 | ASSERT_EQ(Preferences::GetUint("foo.uint", 1, PrefValueKind::User), 99U); |
29 | 0 |
|
30 | 0 | Preferences::SetFloat("foo.float", 3.33f, PrefValueKind::Default); |
31 | 0 | Preferences::SetFloat("foo.float", 4.44f, PrefValueKind::User); |
32 | 0 | ASSERT_FLOAT_EQ( |
33 | 0 | Preferences::GetFloat("foo.float", 1.0f, PrefValueKind::Default), 3.33f); |
34 | 0 | ASSERT_FLOAT_EQ(Preferences::GetFloat("foo.float", 1.0f, PrefValueKind::User), |
35 | 0 | 4.44f); |
36 | 0 | } |