R. Bowen Loftin

31 papers A* 6A 1B 5C 1Journal 8Unranked 9
YearRankTypeTitle / Venue / Authors
2005 ch.
The Visualization Handbook
R. Bowen Loftin, Jim X. Chen, Larry Rosenblum
2004 J jnl
IEEE Computer Graphics and Applications
R. Bowen Loftin, Mark W. Scerbo, Frederic D. McKenzie, Jean M. Catanzaro
2003 J jnl
Presence Teleoperators Virtual Environ.
R. Bowen Loftin, Larry Rosenblum
2003 A* conf
VR
Jim X. Chen, Yonggao Yang, R. Bowen Loftin
2003 J jnl
Comput. Sci. Eng.
R. Bowen Loftin
2002 J jnl
Comput. Graph.
Chris Harding, Ioannis A. Kakadiaris, John F. Casey, R. Bowen Loftin
2002 A* conf
VR
Ching-Yao Lin, David T. Chen, R. Bowen Loftin, Jian Chen, Ernst L. Leiss
2002 A* conf
ICRA
Lorraine E. P. Williams, R. Bowen Loftin, Hal A. Aldridge, Ernst L. Leiss, William Bluethmann
2001 conf
VisSym
Chris Harding, Ioannis A. Kakadiaris, John F. Casey, R. Bowen Loftin
2001 J jnl
Commun. ACM
Simon Su, R. Bowen Loftin
2001 J jnl
Commun. ACM
R. Bowen Loftin
2000 B conf
ICMI
Chris Harding, Ioannis A. Kakadiaris, R. Bowen Loftin
2000 A* conf
VR
Ching-Rong Lin, R. Bowen Loftin, H. Roice Nelson Jr.
2000 A conf
MICCAI
David T. Chen, Ioannis A. Kakadiaris, Michael J. Miller, R. Bowen Loftin, Charles W. Patrick
2000 B conf
VRST
Ching-Rong Lin, R. Bowen Loftin
1999 J jnl
Presence Teleoperators Virtual Environ.
Marilyn C. Salzman, Christopher J. Dede, R. Bowen Loftin, Jim X. Chen
1999 conf
HCI (2)
R. Bowen Loftin
1999 A* conf
CHI
Marilyn C. Salzman, Christopher J. Dede, R. Bowen Loftin
1998 B conf
VRST
Ching-Rong Lin, R. Bowen Loftin
1998 B conf
Intelligent Tutoring Systems
Carol L. Redfield, Benjamin Bell, Patricia Y. Hsieh, Joseph Lamos, R. Bowen Loftin, David Palumbo
1998 B conf
Intelligent Tutoring Systems
Benjamin Bell, Jan Hawkins, R. Bowen Loftin, Tom T. Carey, Alex Kass
1998 conf
VRAIS
R. Bowen Loftin, Frederick P. Brooks Jr., Christopher J. Dede
1998 conf
APCHI
Ching-Rong Lin, R. Bowen Loftin, Tracy Stark
1997 A* conf
SIGGRAPH
William R. Sherman, Nina Adams, Rita K. Addison, R. Bowen Loftin, Ben Britton, Donna J. Cox, Robert Patterson
1997 conf
SIGGRAPH Visual Proceedings
R. Bowen Loftin
1996 conf
ICLS
Chris Dede, Marilyn C. Salzman, R. Bowen Loftin
1996 conf
CHI Conference Companion
Marilyn C. Salzman, R. Bowen Loftin, Christopher J. Dede, Deirdre McGlynn
1996 conf
VRAIS
Christopher J. Dede, Marilyn C. Salzman, R. Bowen Loftin
1995 J jnl
IEEE Computer Graphics and Applications
R. Bowen Loftin, Patrick J. Kenney
1994 conf
MHVR
Christopher J. Dede, Marilyn C. Salzman, R. Bowen Loftin
1989 C conf
IAAI
R. Bowen Loftin, Lui Wang, Paul T. Baffes, Grace Hua
tests/unit/test_decompile_strings.py
← Index tests/unit/test_decompile_strings.py python
"""Unit tests for bninja/analysis/strings.py — StringAnalysis."""
import pytest
import math
from unittest.mock import MagicMock


# StringAnalysis has no binaryninja imports, just collections and math
from redb.extractors.decompiler.bninja.analysis.strings import StringAnalysis


# ============================================================================
# Helper mocks
# ============================================================================

class MockStringEntry:
    """Mock for a Binary Ninja string reference."""
    def __init__(self, value, raw=None, start=0, length=0, type_name="Utf8String"):
        self.value = value
        self.raw = raw if raw is not None else (value.encode("utf-8") if isinstance(value, str) else value)
        self.start = start
        self.length = length if length else len(self.raw)
        self.type = MagicMock()
        self.type.name = type_name


class MockBinaryView:
    """Mock binary view with a strings list."""
    def __init__(self, strings=None):
        self.strings = strings or []


# ============================================================================
# 6a. StringAnalysis
# ============================================================================


class TestStringAnalysisEntropy:
    def setup_method(self):
        self.sa = StringAnalysis(bv=MockBinaryView(), functions=[])

    def test_entropy_empty_string(self):
        assert self.sa.entropy("") == 0.0

    def test_entropy_single_char(self):
        assert self.sa.entropy("aaaa") == 0.0

    def test_entropy_uniform_distribution(self):
        # "abcd" -> 4 unique chars, each p=1/4, entropy = log2(4) = 2.0
        result = self.sa.entropy("abcd")
        assert result == pytest.approx(2.0)

    def test_entropy_binary_string(self):
        # "ab" -> 2 unique chars, each p=1/2, entropy = log2(2) = 1.0
        result = self.sa.entropy("ab")
        assert result == pytest.approx(1.0)


class TestStringAnalysisAnalyze:
    def test_analyze_deduplication(self):
        """Duplicate (string, encoding) pairs -> only first kept."""
        entries = [
            MockStringEntry("hello", start=100, type_name="Utf8String"),
            MockStringEntry("hello", start=200, type_name="Utf8String"),
        ]
        bv = MockBinaryView(strings=entries)
        sa = StringAnalysis(bv=bv, functions=[])
        result = sa.analyze()
        assert len(result) == 1
        assert result[0]["string_offset"] == 100

    def test_analyze_sorted_by_address(self):
        """First occurrence (lowest offset) is the one kept."""
        entries = [
            MockStringEntry("world", start=500, type_name="Utf8String"),
            MockStringEntry("world", start=100, type_name="Utf8String"),
        ]
        bv = MockBinaryView(strings=entries)
        sa = StringAnalysis(bv=bv, functions=[])
        result = sa.analyze()
        assert len(result) == 1
        # The analyze() sorts by start, so 100 comes first
        assert result[0]["string_offset"] == 100

    def test_analyze_empty_bv(self):
        bv = MockBinaryView(strings=[])
        sa = StringAnalysis(bv=bv, functions=[])
        result = sa.analyze()
        assert result == []

    def test_analyze_output_schema(self):
        entries = [MockStringEntry("test_string", start=0, type_name="Utf8String")]
        bv = MockBinaryView(strings=entries)
        sa = StringAnalysis(bv=bv, functions=[])
        result = sa.analyze()
        assert len(result) == 1
        r = result[0]
        required_keys = [
            "string",
            "string_raw",
            "string_encoding",
            "string_offset",
            "string_length",
            "string_raw_length",
            "string_entropy",
        ]
        for key in required_keys:
            assert key in r, f"Missing key: {key}"