Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdd420ec authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

Store flags in order am: be3e76df am: 06b75a72

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1893321

Change-Id: I380f80ac522128ec4368467637c9615d7329a4b4
parents f88a78c5 06b75a72
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,10 +17,10 @@
#pragma once

#include <climits>
#include <map>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>

#include <android-base/thread_annotations.h>
#include <netdutils/DumpWriter.h>
@@ -45,7 +45,7 @@ class Experiments {
    Experiments() = delete;
    void updateInternal() EXCLUDES(mMutex);
    mutable std::mutex mMutex;
    std::unordered_map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex);
    std::map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex);
    // TODO: Migrate other experiment flags to here.
    // (retry_count, retransmission_time_interval)
    static constexpr const char* const kExperimentFlagKeyList[] = {
+4 −4
Original line number Diff line number Diff line
@@ -14,10 +14,10 @@
 * limitations under the License.
 */

#include <map>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>

#include <android-base/format.h>
#include <android-base/test_utils.h>
@@ -72,7 +72,7 @@ class ExperimentsTest : public ::testing::Test {
    }

    void expectGetDnsExperimentFlagInt() {
        std::unordered_map<std::string_view, int> tempMap;
        std::map<std::string_view, int> tempMap;
        for (const auto& key : Experiments::kExperimentFlagKeyList) {
            tempMap[key] = mExperiments.getFlag(key, 0);
        }
@@ -102,11 +102,11 @@ class ExperimentsTest : public ::testing::Test {
        EXPECT_EQ(dumpString.substr(startPos), "\n");
    }

    static std::unordered_map<std::string_view, int> sFakeFlagsMapInt;
    static std::map<std::string_view, int> sFakeFlagsMapInt;
    Experiments mExperiments;
};

std::unordered_map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt;
std::map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt;

TEST_F(ExperimentsTest, update) {
    std::vector<int> testValues = {50, 3, 5, 0};