This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(backend): fix SQLite JSON blob bugs
- Loading branch information
Showing
6 changed files
with
83 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
srcs: 2e1bd3b9f4e7baaf51f43553662842dc | ||
outs: 63faeb2bdfe750e843383133579a0550 | ||
srcs: e80150f42251938329daac92fb5a9c42 | ||
outs: ff29159baa5946b69e98f85b93b400a4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Package strbytes provides convenience wrappers for the *unsafe* []byte <-> string conversions. | ||
// No []byte value must be modified after it has been converted to or from a string. | ||
package strbytes | ||
|
||
import "unsafe" | ||
|
||
// String from bytes. | ||
func String(b []byte) string { | ||
if len(b) == 0 { | ||
return "" | ||
} | ||
|
||
return unsafe.String(&b[0], len(b)) | ||
} | ||
|
||
// Bytes from string. | ||
func Bytes(s string) []byte { | ||
if len(s) == 0 { | ||
return nil | ||
} | ||
|
||
return unsafe.Slice(unsafe.StringData(s), len(s)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package strbytes | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
) | ||
|
||
func TestAll(t *testing.T) { | ||
roundTripString(t, "Hello") | ||
roundTripString(t, "Привет! Как дела?") | ||
roundTripString(t, "Hello, 世界") | ||
roundTripString(t, "Hello, 👨👩👧👦") | ||
roundTripBytes(t, []byte{143, 11, 254, 254, 168}) | ||
} | ||
|
||
func roundTripString(t *testing.T, s string) { | ||
b := Bytes(s) | ||
s2 := String(b) | ||
if s != s2 { | ||
t.Fatalf("expected %q, got %q", s, s2) | ||
} | ||
} | ||
|
||
func roundTripBytes(t *testing.T, b []byte) { | ||
s := String(b) | ||
b2 := Bytes(s) | ||
if string(b) != string(b2) { | ||
t.Fatalf("expected %q, got %q", b, b2) | ||
} | ||
|
||
if !bytes.Equal(b, b2) { | ||
t.Fatalf("expected %q, got %q", b, b2) | ||
} | ||
} |