Skip to content

chore: Dafny test code changes for Python #1911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ module DynamoToStructTest {
//= type=test
//# Entries in a String Set MUST be ordered in ascending [UTF-16 binary order](./string-ordering.md#utf-16-binary-order).
method {:test} TestSortSSAttr() {
var stringSetValue := AttributeValue.SS(["&","。","𐀂"]);
// "\ud800\udc02" <-> "𐀂"
var stringSetValue := AttributeValue.SS(["&","。","\ud800\udc02"]);
// Note that string values are UTF-8 encoded, but sorted by UTF-16 encoding.
var encodedStringSetData := StructuredDataTerminal(value := [
0,0,0,3, // 3 entries in set
Expand All @@ -395,7 +396,8 @@ module DynamoToStructTest {

var newStringSetValue := StructuredToAttr(encodedStringSetData);
expect newStringSetValue.Success?;
expect newStringSetValue.value == AttributeValue.SS(["&","𐀂","。"]);
// "\ud800\udc02" <-> "𐀂"
expect newStringSetValue.value == AttributeValue.SS(["&","\ud800\udc02","。"]);
}

//= specification/dynamodb-encryption-client/ddb-attribute-serialization.md#set-entries
Expand All @@ -415,11 +417,13 @@ module DynamoToStructTest {

method {:test} TestSetsInListAreSorted() {
var nSetValue := AttributeValue.NS(["2","1","10"]);
var sSetValue := AttributeValue.SS(["&","。","𐀂"]);
// "\ud800\udc02" <-> "𐀂"
var sSetValue := AttributeValue.SS(["&","。","\ud800\udc02"]);
var bSetValue := AttributeValue.BS([[1,0],[1],[2]]);

var sortedNSetValue := AttributeValue.NS(["1","10","2"]);
var sortedSSetValue := AttributeValue.SS(["&","𐀂","。"]);
// "\ud800\udc02" <-> "𐀂"
var sortedSSetValue := AttributeValue.SS(["&","\ud800\udc02","。"]);
var sortedBSetValue := AttributeValue.BS([[1],[1,0],[2]]);

var listValue := AttributeValue.L([nSetValue, sSetValue, bSetValue]);
Expand All @@ -444,11 +448,13 @@ module DynamoToStructTest {

method {:test} TestSetsInMapAreSorted() {
var nSetValue := AttributeValue.NS(["2","1","10"]);
var sSetValue := AttributeValue.SS(["&","。","𐀂"]);
// "\ud800\udc02" <-> "𐀂"
var sSetValue := AttributeValue.SS(["&","。","\ud800\udc02"]);
var bSetValue := AttributeValue.BS([[1,0],[1],[2]]);

var sortedNSetValue := AttributeValue.NS(["1","10","2"]);
var sortedSSetValue := AttributeValue.SS(["&","𐀂","。"]);
// "\ud800\udc02" <-> "𐀂"
var sortedSSetValue := AttributeValue.SS(["&","\ud800\udc02","。"]);
var sortedBSetValue := AttributeValue.BS([[1],[1,0],[2]]);

var mapValue := AttributeValue.M(map["keyA" := sSetValue, "keyB" := nSetValue, "keyC" := bSetValue]);
Expand Down Expand Up @@ -490,7 +496,8 @@ module DynamoToStructTest {
method {:test} TestSortMapKeys() {
var nullValue := AttributeValue.NULL(true);

var mapValue := AttributeValue.M(map["&" := nullValue, "。" := nullValue, "𐀂" := nullValue]);
// "\ud800\udc02" <-> "𐀂"
var mapValue := AttributeValue.M(map["&" := nullValue, "。" := nullValue, "\ud800\udc02" := nullValue]);

// Note that the string values are encoded as UTF-8, but are sorted according to UTF-16 encoding.
var encodedMapData := StructuredDataTerminal(
Expand Down
10 changes: 5 additions & 5 deletions TestVectors/dafny/DDBEncryption/src/WriteManifest.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ module {:options "-functionSyntax:4"} WriteManifest {
const DoNothing : CryptoAction := 3

const A : string := "A"
const B : string := "퀀" // Ud000"
const C : string := "" // Ufe4c"
const D : string := "𐀁" // U10001
const E : string := "𐀂" // U10002 - same high surrogate as D
const F : string := "𠀂" // U20002 - different high surrogate as D
const B : string := "\ud000" // "Ud000" <-> "퀀"
const C : string := "\ufe4c" // "Ufe4c" <-> "﹌"
const D : string := "\uD800\uDC01" // "U10001" <-> "𐀁" (surrogate pair: "\uD800\uDC01")
const E : string := "\uD800\uDC02" // "U10002" <-> "𐀂" (same high surrogate as D: "\uD800\uDC02")
const F : string := "\uD840\uDC02" // "U20002" <-> "𠀂" (different high surrogate as D: "\D840\uDC02")

lemma CheckLengths()
ensures |A| == 1
Expand Down
Loading