Skip to content

Complete the test files preliminarily. #13

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 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
736983d
Merge pull request #1 from Chever-John/wrap_exception
Chever-John Aug 10, 2021
0c50a45
Merge pull request #2 from Chever-John/wrap_exception
Chever-John Aug 12, 2021
0011095
Merge remote-tracking branch 'upstream/master'
Aug 13, 2021
620d36d
test: add 'ndef message with uri type'.
Aug 17, 2021
89fe804
test: some tests;
Aug 17, 2021
a33ba33
test: some examples;
Aug 19, 2021
f77d37f
test: some ideas;
Aug 19, 2021
95e4f06
test: finish the test of uri.
Aug 19, 2021
b3af660
test: improved test use cases.
Aug 21, 2021
47bcf85
test: finish the test of URI Record (v2.0).
Aug 24, 2021
163a1ce
test: finish the test of DeviceInfo Record (v1.0).
Aug 25, 2021
487a6b7
test: reformat the codes.
Aug 25, 2021
c46ebc7
Merge pull request #3 from nfcim/master
Chever-John Aug 26, 2021
b39c780
test: finish the test of Smart poster Record(v1.0).
Aug 26, 2021
6cce765
Merge branch 'test_uri'
Aug 26, 2021
c22fa5e
test: transform the complex instance ex.[4, 102, ....] to understanda…
Aug 27, 2021
7598cf4
add .DS_Store to .gitignore.
Aug 27, 2021
d49b2a3
Test: improved test use cases.
Aug 17, 2021
ee91a80
Test: add test files and solve errors.(#11)
Sep 17, 2021
c157c3a
Test: complete handover_test.dart.
Sep 24, 2021
65a8e6d
Test: complete signature_test.dart and delete '.payload' after thinking.
Sep 24, 2021
59b2961
Test: complete text_test.dart.
Sep 24, 2021
e4bc371
Test: fix 2/3 comments from @Harry-Chen
Sep 24, 2021
2b3d5d0
Test: fix all comments from @Harry-Chen
Sep 25, 2021
1474e99
Refactor: format the code.
Sep 28, 2021
d1591ce
Remove ndef_test.dart
Harry-Chen Sep 28, 2021
be2fe74
Reorganize tests
Harry-Chen Sep 28, 2021
bb95359
Format code
Harry-Chen Sep 28, 2021
30f0bb2
Fix: has located the problem
Chever-John Jan 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ndef.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ List<NDEFRecord> decodeRawNdefMessage(Uint8List data,
/// This is most useful in mobile environment because the APIs will give you these information in a separate manner.
NDEFRecord decodePartialNdefMessage(
TypeNameFormat tnf, Uint8List type, Uint8List payload,
{required Uint8List id}) {
{Uint8List? id}) {
var decoded = NDEFRecord.doDecode(tnf, type, payload, id: id);
return decoded;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ class ByteUtils {
}

static Uint8List hexStringToBytes(String hex) {
// Delete blank space
// if there are some blank space in ${hex}, this will delete blank space in it.
hex = hex.splitMapJoin(" ", onMatch: (Match match) {
return "";
});
if (hex.length % 2 != 0) {
throw "Hex string length must be even integer, got ${hex.length}";
throw ArgumentError("Hex string length must be even integer, got ${hex.length}");
}
var result = <int>[];
for (int i = 0; i < hex.length; i += 2) {
Expand Down
23 changes: 23 additions & 0 deletions test/common.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:flutter_test/flutter_test.dart';

import 'package:ndef/ndef.dart';
import 'package:ndef/utilities.dart';

void testParse(List<String> hexStrings, List<List<NDEFRecord>> messages) {
for (int i = 0; i < hexStrings.length; i++) {
List<NDEFRecord> decoded = decodeRawNdefMessage(hexStrings[i].toBytes());
assert(decoded.length == messages[i].length);
for (int j = 0; j < decoded.length; j++) {
assert(decoded[j].isEqual(messages[i][j]));
}
}
}

void testGenerate(List<String> hexStrings, List<List<NDEFRecord>> messages) {
for (int i = 0; i < hexStrings.length; i++) {
assert(encodeNdefMessage(messages[i]).toHexString() == hexStrings[i]);
}
}
305 changes: 0 additions & 305 deletions test/ndef_test.dart

This file was deleted.

30 changes: 30 additions & 0 deletions test/records/bluetooth_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'dart:typed_data';

import 'package:flutter_test/flutter_test.dart';
import 'package:ndef/record.dart';
import 'package:ndef/record/bluetooth.dart';

import '../common.dart';

void main() {
group('decode and encode', () {
test('bluetooth record', () {
List<String> hexStrings = [
"d2200b6170706c69636174696f6e2f766e642e626c7565746f6f74682e65702e6f6f620b0006050403020102ff61",
];

List<List<NDEFRecord>> messages = [
[
BluetoothEasyPairingRecord(
address: EPAddress(address: "06:05:04:03:02:01"),
attributes: {
EIRType.ManufacturerSpecificData: Uint8List.fromList([97])
})
],
];

testParse(hexStrings, messages);
testGenerate(hexStrings, messages);
});
});
}
Loading