Skip to content

Commit

Permalink
bugfix hasRow/hasColumn for A:A 1:1
Browse files Browse the repository at this point in the history
  • Loading branch information
sjhorn committed Apr 26, 2024
1 parent 432689a commit d6bcfd7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.13

- Bug fix for hasRow, hasColumn for whole columns/rows ie. A:A, 1:1 cases

## 1.0.12

- Fixeg bug in hasCorner or the A:A, 2:2 cases ie. whole row or column selection
Expand Down
21 changes: 19 additions & 2 deletions lib/src/a1_range.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,15 @@ class A1Range implements Comparable<A1Range> {
true,

// A:B
(null, null) => true,
(null, null) when from.row == null && to.row == null => true,

// 1:1
(null, null)
when from.row != null &&
row >= from.row! &&
to.row != null &&
row <= to.row! =>
true,
(_, _) when from.isAll && to.isAll => true,
_ => false,
};
Expand Down Expand Up @@ -281,8 +289,17 @@ class A1Range implements Comparable<A1Range> {
to.column != null &&
column <= to.column! =>
true,

// 1:2
(null, null) => true,
(null, null) when from.column == null && to.column == null => true,

// A:A
(null, null)
when from.column != null &&
column >= from.column! &&
to.column != null &&
column <= to.column! =>
true,

// <empty>
(_, _) when from.isAll && to.isAll => true,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: a1
version: 1.0.12
version: 1.0.13

homepage: https://pub.dev/packages/a1
repository: https://github.com/sjhorn/a1
Expand Down
6 changes: 5 additions & 1 deletion test/a1_range_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ void main() {

expect('A:B'.a1Range.hasCorner('A1'.a1), isTrue);
expect('A:A'.a1Range.hasCorner('A1'.a1), isTrue);
expect('A'.a1Range.hasCorner('A1'.a1), isTrue);
expect('1:2'.a1Range.hasCorner('A2'.a1), isTrue);
expect('1:2'.a1Range.hasCorner('A2'.a1), isTrue);
expect('2'.a1Range.hasCorner('A2'.a1), isTrue);
expect('I'.a1Range.hasCorner('I1'.a1), isTrue);
});
test(
'where the to column is greater than the from column, but row is greater',
Expand Down Expand Up @@ -104,6 +106,7 @@ void main() {
expect('A1:2'.a1Range.hasColumn(0), isFalse);
expect('A:B2'.a1Range.hasColumn(0), isTrue);
expect('1:2'.a1Range.hasColumn(0), isTrue);
expect('A:A'.a1Range.hasColumn(1), isFalse);
});
test('hasRow for variages ranges', () {
expect('A1:A2'.a1Range.hasRow(0), isTrue);
Expand All @@ -112,6 +115,7 @@ void main() {
expect('A1:2'.a1Range.hasRow(0), isTrue);
expect('2:B2'.a1Range.hasRow(1), isTrue);
expect('A:B'.a1Range.hasRow(0), isTrue);
expect('1:1'.a1Range.hasRow(1), isFalse);
});
});

Expand Down

0 comments on commit d6bcfd7

Please sign in to comment.