-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from vlang/master
Small cleanup to the `x.encoding.asn1` module
- Loading branch information
Showing
5 changed files
with
78 additions
and
2 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
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
29 changes: 29 additions & 0 deletions
29
vlib/v/tests/generics/generics_with_empty_array_arg_test.v
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,29 @@ | ||
fn count_str(array []string) int { | ||
return array.len | ||
} | ||
|
||
fn count_int(array []int) int { | ||
return array.len | ||
} | ||
|
||
fn count[T](array []T) int { | ||
return array.len | ||
} | ||
|
||
fn test_generics_with_empty_array_arg() { | ||
assert count_str(['one', 'two']) == 2 | ||
assert count_str([]string{}) == 0 | ||
assert count_str([]) == 0 | ||
|
||
assert count_int([1, 2]) == 2 | ||
assert count_int([]int{}) == 0 | ||
assert count_int([]) == 0 | ||
|
||
assert count[f64]([1.0, 2.0]) == 2 | ||
assert count[f64]([]f64{}) == 0 | ||
assert count[f64]([]) == 0 | ||
|
||
assert count[int]([1, 2]) == 2 | ||
assert count[int]([]int{}) == 0 | ||
assert count[int]([]) == 0 | ||
} |
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,35 @@ | ||
import time | ||
import db.sqlite | ||
|
||
@[table: 'task_metadata'] | ||
struct TaskMetadata { | ||
id string @[primary] | ||
task_id string | ||
key string | ||
value string | ||
created_at time.Time @[default: 'CURRENT_TIME'] | ||
updated_at time.Time @[default: 'CURRENT_TIME'] | ||
} | ||
|
||
@[table: 'tasks'] | ||
struct Task { | ||
id string @[primary] | ||
name string | ||
metadata []TaskMetadata @[fkey: 'task_id'] | ||
} | ||
|
||
struct MyService { | ||
mut: | ||
db sqlite.DB | ||
} | ||
|
||
pub fn (s MyService) create(record Task) int { | ||
result := sql s.db { | ||
insert record into Task | ||
} or { return -1 } | ||
return result | ||
} | ||
|
||
fn test_main() { | ||
assert true | ||
} |