summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYikai Zhao <i@blahgeek.com>2021-08-14 13:46:30 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-08-14 13:46:37 +0200
commitadb6c3f1a4cc5ec3d26bfb2311dfc87b965153a0 (patch)
tree09c17b004c1081dfd11353038f64d3e7b11cd5c8 /test
parent37d48edf6d406a4730caa0393f7695de2bfadfcc (diff)
downloademacs-adb6c3f1a4cc5ec3d26bfb2311dfc87b965153a0.tar.gz
Fix memory-report counting of vector/hash table sizes
* lisp/emacs-lisp/memory-report.el (memory-report--object-size-1): Count element values in vectors and hash tables. Copyright-paperwork-exempt: yes
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/memory-report-tests.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/memory-report-tests.el b/test/lisp/emacs-lisp/memory-report-tests.el
index da5f4f5700f..0c0297b5fce 100644
--- a/test/lisp/emacs-lisp/memory-report-tests.el
+++ b/test/lisp/emacs-lisp/memory-report-tests.el
@@ -45,6 +45,7 @@
(should (equal (memory-report-object-size (list 'foo)) 16))
+ (should (equal (memory-report-object-size (vector 1 2 3)) 64))
(should (equal (memory-report-object-size (vector 1 2 3 4)) 80))
(should (equal (memory-report-object-size "") 32))
@@ -52,6 +53,21 @@
(should (equal (memory-report-object-size (propertize "a" 'face 'foo))
81)))
+(ert-deftest memory-report-sizes-vectors ()
+ (should (= (memory-report--object-size
+ (make-hash-table :test #'eq)
+ ["long string that should be at least 40 bytes"])
+ 108))
+ (let ((string "long string that should be at least 40 bytes"))
+ (should (= (memory-report--object-size
+ (make-hash-table :test #'eq)
+ (vector string))
+ 108))
+ (should (= (memory-report--object-size
+ (make-hash-table :test #'eq)
+ (vector string string))
+ 124))))
+
(provide 'memory-report-tests)
;;; memory-report-tests.el ends here