| 1 | // Copyright 2024 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package opaque_map_testscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/cmd/protoc-gen-go/opaque_map_test_test`/ |
| 6 | |
| 7 | import ( |
| 8 | "testingscip-go gomod github.com/golang/go/src go1.23 testing/" |
| 9 | |
| 10 | testopaquepbscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/ "google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaquescip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/" |
| 11 | ) |
| 12 | |
| 13 | func TestOpaqueMapscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/cmd/protoc-gen-go/opaque_map_test_test`/TestOpaqueMap().(t *testingscip-go gomod github.com/golang/go/src go1.23 testing/.Tscip-go gomod github.com/golang/go/src go1.23 testing/T#) { |
| 14 | m := &testopaquepbscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/.TestAllTypesscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#{} |
| 15 | |
| 16 | m.SetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#SetMapStringString().(map[string]string{"one": "eins"}) |
| 17 | if got, want := len(m.GetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#GetMapStringString().()), 1; got != want { |
| 18 | t.Errorfscip-go gomod github.com/golang/go/src go1.23 testing/common#Errorf().("after setting map_string_string to a non-empty map: len(m.GetMapStringString()) = %v, want %v", got, want) |
| 19 | } |
| 20 | delete(m.GetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#GetMapStringString().(), "one") |
| 21 | if got, want := len(m.GetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#GetMapStringString().()), 0; got != want { |
| 22 | t.Errorfscip-go gomod github.com/golang/go/src go1.23 testing/common#Errorf().("after removing all elements from m_one: len(m.GetMapStringString()) = %v, want %v", got, want) |
| 23 | } |
| 24 | if got := m.GetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#GetMapStringString().(); got == nil { |
| 25 | t.Errorfscip-go gomod github.com/golang/go/src go1.23 testing/common#Errorf().("after removing all elements from m_one: m.GetMapStringString() = nil, want non-nil map") |
| 26 | } |
| 27 | m.GetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#GetMapStringString().()["two"] = "zwei" |
| 28 | if got, want := len(m.GetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#GetMapStringString().()), 1; got != want { |
| 29 | t.Errorfscip-go gomod github.com/golang/go/src go1.23 testing/common#Errorf().("after adding new element to m_one: len(m.GetMapStringString()) = %v, want %v", got, want) |
| 30 | } |
| 31 | m.SetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#SetMapStringString().(map[string]string{}) |
| 32 | if got := m.GetMapStringStringscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/TestAllTypes#GetMapStringString().(); got == nil { |
| 33 | t.Errorfscip-go gomod github.com/golang/go/src go1.23 testing/common#Errorf().("after setting m_one to an empty map: m.GetMapStringString() = nil, want non-nil map") |
| 34 | } |
| 35 | } |