Skip to content

Commit b15b231

Browse files
committed
Change the behavior the Octal
- adds coverage - change argument types - use custom implementation for Base-8, Base-16
1 parent 38fe74e commit b15b231

28 files changed

Lines changed: 585 additions & 267 deletions

.github/workflows/test.yml

Lines changed: 84 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,61 @@
1-
name: test
1+
name: Test
22

33
on:
44
workflow_dispatch:
55
push:
66
branches: [master]
7-
paths: ["**.dart", "**.yaml"]
7+
paths: ['**.dart', '**.yaml', '**.yml']
88
pull_request:
99
branches: [master]
10-
paths: ["**.dart", "**.yaml"]
11-
schedule:
12-
- cron: "0 0 * * 5" # m h d M w
10+
paths: ['**.dart', '**.yaml', '**.yml']
1311

1412
jobs:
15-
build:
13+
coverage:
1614
if: github.repository == 'bitanon/hashlib_codecs'
17-
runs-on: ${{ matrix.os }}
1815
strategy:
1916
matrix:
20-
os: [ubuntu-latest] # macos-latest, windows-latest
21-
sdk: ["2.14.0", "2.19.6", "stable", "dev"]
17+
os: [ubuntu-latest]
18+
sdk: ['stable']
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: dart-lang/setup-dart@v1
24+
with:
25+
sdk: ${{ matrix.sdk }}
26+
27+
- name: 'Install global packages'
28+
run: |
29+
dart pub global activate coverage
30+
dart pub global activate cobertura
31+
dart pub global activate junitreport
32+
33+
- name: Run tests with coverage
34+
run: bash ./scripts/coverage.sh
35+
36+
- name: Upload results to Codecov
37+
uses: codecov/codecov-action@v4
38+
with:
39+
token: ${{ secrets.CODECOV_TOKEN }}
40+
file: ./coverage/cobertura.xml
2241

42+
- name: Upload test results to Codecov
43+
if: ${{ !cancelled() }}
44+
uses: codecov/test-results-action@v1
45+
with:
46+
token: ${{ secrets.CODECOV_TOKEN }}
47+
file: ./coverage/junit.xml
48+
49+
test-on-stable:
50+
strategy:
51+
matrix:
52+
os: [ubuntu-latest, macos-latest, windows-latest]
53+
sdk: ['stable']
54+
runs-on: ${{ matrix.os }}
2355
steps:
24-
- uses: actions/checkout@v3
56+
- uses: actions/checkout@v4
2557

26-
# You can specify other versions if desired, see documentation here:
27-
# https://github.com/dart-lang/setup-dart/blob/main/README.md
28-
- uses: dart-lang/setup-dart@v1.3
58+
- uses: dart-lang/setup-dart@v1
2959
with:
3060
sdk: ${{ matrix.sdk }}
3161

@@ -38,12 +68,46 @@ jobs:
3868
- name: Analyze project source
3969
run: dart analyze --fatal-infos
4070

41-
- if: matrix.sdk != '2.14.0'
42-
name: Generate documentation
43-
run: dart doc --validate-links
71+
- name: Run tests
72+
run: dart test
73+
74+
test-on-legacy:
75+
strategy:
76+
matrix:
77+
os: [ubuntu-latest, windows-latest]
78+
sdk: ['2.14']
79+
runs-on: ${{ matrix.os }}
80+
steps:
81+
- uses: actions/checkout@v4
82+
83+
- uses: dart-lang/setup-dart@v1
84+
with:
85+
sdk: ${{ matrix.sdk }}
86+
87+
- name: Run tests
88+
run: dart test
89+
90+
test-on-beta:
91+
strategy:
92+
matrix:
93+
os: [ubuntu-latest]
94+
sdk: ['beta']
95+
runs-on: ${{ matrix.os }}
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- uses: dart-lang/setup-dart@v1
100+
with:
101+
sdk: ${{ matrix.sdk }}
102+
103+
- name: Install dependencies
104+
run: dart pub get
44105

45-
- name: Run tests on vm
46-
run: dart test -p vm
106+
- name: Verify formatting
107+
run: dart format --output=none --set-exit-if-changed .
108+
109+
- name: Analyze project source
110+
run: dart analyze --fatal-infos
47111

48-
- name: Run tests on node
49-
run: dart test -p node
112+
- name: Run tests
113+
run: dart test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
.dart_tool/
44
.packages
55

6-
# Conventional directory for build outputs.
6+
# Conventional directory for outputs.
77
build/
88
doc/
9+
coverage/
910
benchmark/**/*.exe
1011
test/**/*.exe
1112

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 2.6.0
2+
3+
- [**Breaking Changes**]
4+
- Change the behavior of the Base-8 encoder to follow the standard
5+
- Accept only `List<int>` instead of `Iterable<int>` in converters
6+
17
# 2.5.0
28

39
- Support UTF-8 encoding and decoding.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Hashlib Codecs
22

33
[![plugin version](https://img.shields.io/pub/v/hashlib_codecs?label=pub)](https://pub.dev/packages/hashlib_codecs)
4-
[![dependencies](https://img.shields.io/badge/dependencies-zero-889)](https://github.com/bitanon/hashlib_codecs/blob/master/pubspec.yaml)
5-
[![dart support](https://img.shields.io/badge/dart-%3e%3d%202.14.0-39f?logo=dart)](https://dart.dev/guides/whats-new#september-8-2021-214-release)
4+
[![test](https://github.com/bitanon/hashlib_codecs/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/bitanon/hashlib_codecs/actions/workflows/test.yml)
5+
[![codecov](https://codecov.io/gh/bitanon/hashlib_codecs/graph/badge.svg?token=ISIYJ8MNI0)](https://codecov.io/gh/bitanon/hashlib_codecs)
66
[![likes](https://img.shields.io/pub/likes/hashlib_codecs?logo=dart)](https://pub.dev/packages/hashlib_codecs/score)
77
[![pub points](https://img.shields.io/pub/points/hashlib_codecs?logo=dart&color=teal)](https://pub.dev/packages/hashlib_codecs/score)
88
[![popularity](https://img.shields.io/pub/popularity/hashlib_codecs?logo=dart)](https://pub.dev/packages/hashlib_codecs/score)
9+
[![dart support](https://img.shields.io/badge/dart-%3e%3d%202.14.0-39f?logo=dart)](https://dart.dev/guides/whats-new#september-8-2021-214-release)
10+
[![dependencies](https://img.shields.io/badge/dependencies-zero-889)](https://github.com/bitanon/hashlib_codecs/blob/master/pubspec.yaml)
911

1012
<!-- [![test](https://github.com/bitanon/hashlib_codecs/actions/workflows/test.yml/badge.svg)](https://github.com/bitanon/hashlib_codecs/actions/workflows/test.yml) -->
1113

dart_test.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ concurrency: 8
55
platforms: [vm, node]
66

77
tags:
8-
skip-js:
8+
vm-only:
9+
skip: true
910
on_platform:
10-
node:
11-
skip: true
11+
vm:
12+
skip: false

lib/src/base16.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Base16Codec _codecFromParameters({
2323
/// - [codec] is the [Base16Codec] to use. It is derived from the other
2424
/// parameters if not provided.
2525
String toHex(
26-
Iterable<int> input, {
26+
List<int> input, {
2727
Base16Codec? codec,
2828
bool upper = false,
2929
}) {
@@ -49,6 +49,5 @@ Uint8List fromHex(
4949
Base16Codec? codec,
5050
}) {
5151
codec ??= _codecFromParameters();
52-
var out = codec.decoder.convert(input.codeUnits);
53-
return Uint8List.fromList(out as List<int>);
52+
return codec.decoder.convert(input.codeUnits);
5453
}

lib/src/base2.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import 'codecs/base2.dart';
1717
/// toBigInt(input).toRadixString(2)
1818
/// ```
1919
String toBinary(
20-
Iterable<int> input, {
20+
List<int> input, {
2121
Base2Codec codec = Base2Codec.standard,
2222
}) {
2323
var out = codec.encoder.convert(input);
@@ -44,6 +44,5 @@ Uint8List fromBinary(
4444
String input, {
4545
Base2Codec codec = Base2Codec.standard,
4646
}) {
47-
var out = codec.decoder.convert(input.codeUnits);
48-
return Uint8List.fromList(out as List<int>);
47+
return codec.decoder.convert(input.codeUnits);
4948
}

lib/src/base32.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const _codecsWithPadding = {
3838
/// - [codec] is the [Base32Codec] to use. It is derived from the other
3939
/// parameters if not provided.
4040
String toBase32(
41-
Iterable<int> input, {
41+
List<int> input, {
4242
Base32Codec? codec,
4343
bool lower = false,
4444
bool padding = true,
@@ -47,7 +47,7 @@ String toBase32(
4747
lower: lower,
4848
padding: padding,
4949
);
50-
var out = codec.encoder.convert(input);
50+
Iterable<int> out = codec.encoder.convert(input);
5151
if (!padding && _codecsWithPadding.contains(codec)) {
5252
out = out.takeWhile((x) => x != codec!.encoder.padding);
5353
}
@@ -76,5 +76,5 @@ Uint8List fromBase32(
7676
}) {
7777
codec ??= _codecFromParameters(padding: padding);
7878
var out = codec.decoder.convert(input.codeUnits);
79-
return Uint8List.fromList(out as List<int>);
79+
return Uint8List.fromList(out);
8080
}

lib/src/base64.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const _codecsWithPadding = {
3434
/// - [codec] is the [Base64Codec] to use. It is derived from the other
3535
/// parameters if not provided.
3636
String toBase64(
37-
Iterable<int> input, {
37+
List<int> input, {
3838
Base64Codec? codec,
3939
bool url = false,
4040
bool padding = true,
@@ -43,7 +43,7 @@ String toBase64(
4343
url: url,
4444
padding: padding,
4545
);
46-
var out = codec.encoder.convert(input);
46+
Iterable<int> out = codec.encoder.convert(input);
4747
if (!padding && _codecsWithPadding.contains(codec)) {
4848
out = out.takeWhile((x) => x != codec!.encoder.padding);
4949
}
@@ -73,5 +73,5 @@ Uint8List fromBase64(
7373
}) {
7474
codec ??= _codecFromParameters(padding: padding);
7575
var out = codec.decoder.convert(input.codeUnits);
76-
return Uint8List.fromList(out as List<int>);
76+
return Uint8List.fromList(out);
7777
}

lib/src/base8.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import 'codecs/base8.dart';
1717
/// toBigInt(input).toRadixString(8)
1818
/// ```
1919
String toOctal(
20-
Iterable<int> input, {
20+
List<int> input, {
2121
Base8Codec codec = Base8Codec.standard,
2222
}) {
2323
var out = codec.encoder.convert(input);
@@ -44,6 +44,5 @@ Uint8List fromOctal(
4444
String input, {
4545
Base8Codec codec = Base8Codec.standard,
4646
}) {
47-
var out = codec.decoder.convert(input.codeUnits);
48-
return Uint8List.fromList(out as List<int>);
47+
return codec.decoder.convert(input.codeUnits);
4948
}

0 commit comments

Comments
 (0)