Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
35d0b435
Commit
35d0b435
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Plain Diff
Merge branch 'development' into dev/update-bindings
parents
ac6bf60b
ceb3fc62
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!102
Release 1.0.0
,
!67
Update Bindings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/XXClient/Models/Fact.swift
+8
-2
8 additions, 2 deletions
Sources/XXClient/Models/Fact.swift
Tests/XXClientTests/Models/FactTests.swift
+13
-0
13 additions, 0 deletions
Tests/XXClientTests/Models/FactTests.swift
with
21 additions
and
2 deletions
Sources/XXClient/Models/Fact.swift
+
8
−
2
View file @
35d0b435
...
@@ -30,10 +30,16 @@ extension Fact: Codable {
...
@@ -30,10 +30,16 @@ extension Fact: Codable {
extension
Array
where
Element
==
Fact
{
extension
Array
where
Element
==
Fact
{
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
try
JSONDecoder
()
.
decode
(
Self
.
self
,
from
:
data
)
if
let
string
=
String
(
data
:
data
,
encoding
:
.
utf8
),
string
==
"null"
{
return
[]
}
return
try
JSONDecoder
()
.
decode
(
Self
.
self
,
from
:
data
)
}
}
public
func
encode
()
throws
->
Data
{
public
func
encode
()
throws
->
Data
{
try
JSONEncoder
()
.
encode
(
self
)
if
isEmpty
{
return
"null"
.
data
(
using
:
.
utf8
)
!
}
return
try
JSONEncoder
()
.
encode
(
self
)
}
}
}
}
This diff is collapsed.
Click to expand it.
Tests/XXClientTests/Models/FactTests.swift
+
13
−
0
View file @
35d0b435
...
@@ -38,4 +38,17 @@ final class FactTests: XCTestCase {
...
@@ -38,4 +38,17 @@ final class FactTests: XCTestCase {
XCTAssertNoDifference
(
models
,
decodedModels
)
XCTAssertNoDifference
(
models
,
decodedModels
)
}
}
func
testCodingEmptyArray
()
throws
{
let
jsonString
=
"null"
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
decodedModels
=
try
[
Fact
]
.
decode
(
jsonData
)
XCTAssertNoDifference
(
decodedModels
,
[])
let
encodedModels
=
try
decodedModels
.
encode
()
XCTAssertNoDifference
(
encodedModels
,
jsonData
)
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment